Mercurial > hg > piper-cpp
changeset 97:427c4c725085
Bring in the Request/Response classes that were in the Vamp SDK, adding them to vamp-support in here instead
line wrap: on
line diff
--- a/vamp-capnp/VampnProto.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-capnp/VampnProto.h Thu Oct 13 18:05:35 2016 +0100 @@ -39,15 +39,16 @@ #include <vamp-hostsdk/Plugin.h> #include <vamp-hostsdk/PluginLoader.h> -#include <vamp-hostsdk/PluginStaticData.h> -#include <vamp-hostsdk/PluginConfiguration.h> -#include <vamp-hostsdk/RequestResponse.h> + +#include "vamp-support/PluginStaticData.h" +#include "vamp-support/PluginConfiguration.h" +#include "vamp-support/RequestResponse.h" #include "vamp-support/PluginHandleMapper.h" #include "vamp-support/PluginOutputIdMapper.h" #include "vamp-support/RequestResponseType.h" -namespace piper +namespace piper_vamp { /** @@ -92,44 +93,46 @@ t.maxValue = m.getMaxValue(); } - static void buildRealTime(RealTime::Builder &b, const Vamp::RealTime &t) { + static void buildRealTime(piper::RealTime::Builder &b, + const Vamp::RealTime &t) { b.setSec(t.sec); b.setNsec(t.nsec); } - static void readRealTime(Vamp::RealTime &t, const RealTime::Reader &r) { + static void readRealTime(Vamp::RealTime &t, + const piper::RealTime::Reader &r) { t.sec = r.getSec(); t.nsec = r.getNsec(); } - static SampleType + static piper::SampleType fromSampleType(Vamp::Plugin::OutputDescriptor::SampleType t) { switch (t) { case Vamp::Plugin::OutputDescriptor::OneSamplePerStep: - return SampleType::ONE_SAMPLE_PER_STEP; + return piper::SampleType::ONE_SAMPLE_PER_STEP; case Vamp::Plugin::OutputDescriptor::FixedSampleRate: - return SampleType::FIXED_SAMPLE_RATE; + return piper::SampleType::FIXED_SAMPLE_RATE; case Vamp::Plugin::OutputDescriptor::VariableSampleRate: - return SampleType::VARIABLE_SAMPLE_RATE; + return piper::SampleType::VARIABLE_SAMPLE_RATE; } throw std::logic_error("unexpected Vamp SampleType enum value"); } static Vamp::Plugin::OutputDescriptor::SampleType - toSampleType(SampleType t) { + toSampleType(piper::SampleType t) { switch (t) { - case SampleType::ONE_SAMPLE_PER_STEP: + case piper::SampleType::ONE_SAMPLE_PER_STEP: return Vamp::Plugin::OutputDescriptor::OneSamplePerStep; - case SampleType::FIXED_SAMPLE_RATE: + case piper::SampleType::FIXED_SAMPLE_RATE: return Vamp::Plugin::OutputDescriptor::FixedSampleRate; - case SampleType::VARIABLE_SAMPLE_RATE: + case piper::SampleType::VARIABLE_SAMPLE_RATE: return Vamp::Plugin::OutputDescriptor::VariableSampleRate; } throw std::logic_error("unexpected Capnp SampleType enum value"); } static void - buildConfiguredOutputDescriptor(ConfiguredOutputDescriptor::Builder &b, + buildConfiguredOutputDescriptor(piper::ConfiguredOutputDescriptor::Builder &b, const Vamp::Plugin::OutputDescriptor &od) { b.setUnit(od.unit); @@ -161,7 +164,7 @@ } static void - buildOutputDescriptor(OutputDescriptor::Builder &b, + buildOutputDescriptor(piper::OutputDescriptor::Builder &b, const Vamp::Plugin::OutputDescriptor &od) { auto basic = b.initBasic(); @@ -173,7 +176,7 @@ static void readConfiguredOutputDescriptor(Vamp::Plugin::OutputDescriptor &od, - const ConfiguredOutputDescriptor::Reader &r) { + const piper::ConfiguredOutputDescriptor::Reader &r) { od.unit = r.getUnit(); @@ -204,14 +207,14 @@ static void readOutputDescriptor(Vamp::Plugin::OutputDescriptor &od, - const OutputDescriptor::Reader &r) { + const piper::OutputDescriptor::Reader &r) { readBasicDescriptor(od, r.getBasic()); readConfiguredOutputDescriptor(od, r.getConfigured()); } static void - buildParameterDescriptor(ParameterDescriptor::Builder &b, + buildParameterDescriptor(piper::ParameterDescriptor::Builder &b, const Vamp::Plugin::ParameterDescriptor &pd) { auto basic = b.initBasic(); @@ -238,7 +241,7 @@ static void readParameterDescriptor(Vamp::Plugin::ParameterDescriptor &pd, - const ParameterDescriptor::Reader &r) { + const piper::ParameterDescriptor::Reader &r) { readBasicDescriptor(pd, r.getBasic()); @@ -261,7 +264,7 @@ } static void - buildFeature(Feature::Builder &b, + buildFeature(piper::Feature::Builder &b, const Vamp::Plugin::Feature &f) { b.setHasTimestamp(f.hasTimestamp); @@ -288,7 +291,7 @@ static void readFeature(Vamp::Plugin::Feature &f, - const Feature::Reader &r) { + const piper::Feature::Reader &r) { f.hasTimestamp = r.getHasTimestamp(); if (f.hasTimestamp) { @@ -310,7 +313,7 @@ } static void - buildFeatureSet(FeatureSet::Builder &b, + buildFeatureSet(piper::FeatureSet::Builder &b, const Vamp::Plugin::FeatureSet &fs, const PluginOutputIdMapper &omapper) { @@ -330,7 +333,7 @@ static void readFeatureSet(Vamp::Plugin::FeatureSet &fs, - const FeatureSet::Reader &r, + const piper::FeatureSet::Reader &r, const PluginOutputIdMapper &omapper) { fs.clear(); @@ -347,24 +350,24 @@ } } - static InputDomain + static piper::InputDomain fromInputDomain(Vamp::Plugin::InputDomain d) { switch(d) { case Vamp::Plugin::TimeDomain: - return InputDomain::TIME_DOMAIN; + return piper::InputDomain::TIME_DOMAIN; case Vamp::Plugin::FrequencyDomain: - return InputDomain::FREQUENCY_DOMAIN; + return piper::InputDomain::FREQUENCY_DOMAIN; default: throw std::logic_error("unexpected Vamp InputDomain enum value"); } } static Vamp::Plugin::InputDomain - toInputDomain(InputDomain d) { + toInputDomain(piper::InputDomain d) { switch(d) { - case InputDomain::TIME_DOMAIN: + case piper::InputDomain::TIME_DOMAIN: return Vamp::Plugin::TimeDomain; - case InputDomain::FREQUENCY_DOMAIN: + case piper::InputDomain::FREQUENCY_DOMAIN: return Vamp::Plugin::FrequencyDomain; default: throw std::logic_error("unexpected Capnp InputDomain enum value"); @@ -372,8 +375,8 @@ } static void - buildExtractorStaticData(ExtractorStaticData::Builder &b, - const Vamp::HostExt::PluginStaticData &d) { + buildExtractorStaticData(piper::ExtractorStaticData::Builder &b, + const PluginStaticData &d) { b.setKey(d.pluginKey); @@ -416,8 +419,8 @@ } static void - readExtractorStaticData(Vamp::HostExt::PluginStaticData &d, - const ExtractorStaticData::Reader &r) { + readExtractorStaticData(PluginStaticData &d, + const piper::ExtractorStaticData::Reader &r) { d.pluginKey = r.getKey(); @@ -455,15 +458,15 @@ d.basicOutputInfo.clear(); auto oo = r.getBasicOutputInfo(); for (auto o: oo) { - Vamp::HostExt::PluginStaticData::Basic b; + PluginStaticData::Basic b; readBasicDescriptor(b, o); d.basicOutputInfo.push_back(b); } } static void - buildConfiguration(Configuration::Builder &b, - const Vamp::HostExt::PluginConfiguration &c) { + buildConfiguration(piper::Configuration::Builder &b, + const PluginConfiguration &c) { const auto &vparams = c.parameterValues; auto params = b.initParameterValues(vparams.size()); @@ -481,8 +484,8 @@ } static void - readConfiguration(Vamp::HostExt::PluginConfiguration &c, - const Configuration::Reader &r) { + readConfiguration(PluginConfiguration &c, + const piper::Configuration::Reader &r) { auto pp = r.getParameterValues(); for (const auto &p: pp) { @@ -496,34 +499,34 @@ } static void - readListResponse(Vamp::HostExt::ListResponse &lr, - const ListResponse::Reader &r) { + readListResponse(ListResponse &lr, + const piper::ListResponse::Reader &r) { lr.available.clear(); auto pp = r.getAvailable(); for (const auto &p: pp) { - Vamp::HostExt::PluginStaticData psd; + PluginStaticData psd; readExtractorStaticData(psd, p); lr.available.push_back(psd); } } static void - buildLoadRequest(LoadRequest::Builder &r, - const Vamp::HostExt::LoadRequest &req) { + buildLoadRequest(piper::LoadRequest::Builder &r, + const LoadRequest &req) { r.setKey(req.pluginKey); r.setInputSampleRate(req.inputSampleRate); - std::vector<AdapterFlag> flags; + std::vector<piper::AdapterFlag> flags; if (req.adapterFlags & Vamp::HostExt::PluginLoader::ADAPT_INPUT_DOMAIN) { - flags.push_back(AdapterFlag::ADAPT_INPUT_DOMAIN); + flags.push_back(piper::AdapterFlag::ADAPT_INPUT_DOMAIN); } if (req.adapterFlags & Vamp::HostExt::PluginLoader::ADAPT_CHANNEL_COUNT) { - flags.push_back(AdapterFlag::ADAPT_CHANNEL_COUNT); + flags.push_back(piper::AdapterFlag::ADAPT_CHANNEL_COUNT); } if (req.adapterFlags & Vamp::HostExt::PluginLoader::ADAPT_BUFFER_SIZE) { - flags.push_back(AdapterFlag::ADAPT_BUFFER_SIZE); + flags.push_back(piper::AdapterFlag::ADAPT_BUFFER_SIZE); } auto f = r.initAdapterFlags(flags.size()); @@ -533,8 +536,8 @@ } static void - readLoadRequest(Vamp::HostExt::LoadRequest &req, - const LoadRequest::Reader &r) { + readLoadRequest(LoadRequest &req, + const piper::LoadRequest::Reader &r) { req.pluginKey = r.getKey(); req.inputSampleRate = r.getInputSampleRate(); @@ -542,13 +545,13 @@ int flags = 0; auto aa = r.getAdapterFlags(); for (auto a: aa) { - if (a == AdapterFlag::ADAPT_INPUT_DOMAIN) { + if (a == piper::AdapterFlag::ADAPT_INPUT_DOMAIN) { flags |= Vamp::HostExt::PluginLoader::ADAPT_INPUT_DOMAIN; } - if (a == AdapterFlag::ADAPT_CHANNEL_COUNT) { + if (a == piper::AdapterFlag::ADAPT_CHANNEL_COUNT) { flags |= Vamp::HostExt::PluginLoader::ADAPT_CHANNEL_COUNT; } - if (a == AdapterFlag::ADAPT_BUFFER_SIZE) { + if (a == piper::AdapterFlag::ADAPT_BUFFER_SIZE) { flags |= Vamp::HostExt::PluginLoader::ADAPT_BUFFER_SIZE; } } @@ -556,8 +559,8 @@ } static void - buildLoadResponse(LoadResponse::Builder &b, - const Vamp::HostExt::LoadResponse &resp, + buildLoadResponse(piper::LoadResponse::Builder &b, + const LoadResponse &resp, const PluginHandleMapper &pmapper) { b.setHandle(pmapper.pluginToHandle(resp.plugin)); @@ -568,8 +571,8 @@ } static void - readLoadResponse(Vamp::HostExt::LoadResponse &resp, - const LoadResponse::Reader &r, + readLoadResponse(LoadResponse &resp, + const piper::LoadResponse::Reader &r, const PluginHandleMapper &pmapper) { resp.plugin = pmapper.handleToPlugin(r.getHandle()); @@ -579,8 +582,8 @@ } static void - buildConfigurationRequest(ConfigurationRequest::Builder &b, - const Vamp::HostExt::ConfigurationRequest &cr, + buildConfigurationRequest(piper::ConfigurationRequest::Builder &b, + const ConfigurationRequest &cr, const PluginHandleMapper &pmapper) { b.setHandle(pmapper.pluginToHandle(cr.plugin)); @@ -589,8 +592,8 @@ } static void - readConfigurationRequest(Vamp::HostExt::ConfigurationRequest &cr, - const ConfigurationRequest::Reader &r, + readConfigurationRequest(ConfigurationRequest &cr, + const piper::ConfigurationRequest::Reader &r, const PluginHandleMapper &pmapper) { auto h = r.getHandle(); @@ -600,8 +603,8 @@ } static void - buildConfigurationResponse(ConfigurationResponse::Builder &b, - const Vamp::HostExt::ConfigurationResponse &cr, + buildConfigurationResponse(piper::ConfigurationResponse::Builder &b, + const ConfigurationResponse &cr, const PluginHandleMapper &pmapper) { b.setHandle(pmapper.pluginToHandle(cr.plugin)); @@ -613,8 +616,8 @@ } static void - readConfigurationResponse(Vamp::HostExt::ConfigurationResponse &cr, - const ConfigurationResponse::Reader &r, + readConfigurationResponse(ConfigurationResponse &cr, + const piper::ConfigurationResponse::Reader &r, const PluginHandleMapper &pmapper) { cr.plugin = pmapper.handleToPlugin(r.getHandle()); @@ -628,7 +631,7 @@ } static void - buildProcessInput(ProcessInput::Builder &b, + buildProcessInput(piper::ProcessInput::Builder &b, Vamp::RealTime timestamp, const std::vector<std::vector<float> > &buffers) { @@ -648,7 +651,7 @@ static void readProcessInput(Vamp::RealTime ×tamp, std::vector<std::vector<float> > &buffers, - const ProcessInput::Reader &b) { + const piper::ProcessInput::Reader &b) { readRealTime(timestamp, b.getTimestamp()); buffers.clear(); @@ -663,8 +666,8 @@ } static void - buildProcessRequest(ProcessRequest::Builder &b, - const Vamp::HostExt::ProcessRequest &pr, + buildProcessRequest(piper::ProcessRequest::Builder &b, + const ProcessRequest &pr, const PluginHandleMapper &pmapper) { b.setHandle(pmapper.pluginToHandle(pr.plugin)); @@ -673,8 +676,8 @@ } static void - readProcessRequest(Vamp::HostExt::ProcessRequest &pr, - const ProcessRequest::Reader &r, + readProcessRequest(ProcessRequest &pr, + const piper::ProcessRequest::Reader &r, const PluginHandleMapper &pmapper) { auto h = r.getHandle(); @@ -683,8 +686,8 @@ } static void - buildProcessResponse(ProcessResponse::Builder &b, - const Vamp::HostExt::ProcessResponse &pr, + buildProcessResponse(piper::ProcessResponse::Builder &b, + const ProcessResponse &pr, const PluginHandleMapper &pmapper) { b.setHandle(pmapper.pluginToHandle(pr.plugin)); @@ -694,8 +697,8 @@ } static void - readProcessResponse(Vamp::HostExt::ProcessResponse &pr, - const ProcessResponse::Reader &r, + readProcessResponse(ProcessResponse &pr, + const piper::ProcessResponse::Reader &r, const PluginHandleMapper &pmapper) { auto h = r.getHandle(); @@ -705,8 +708,8 @@ } static void - buildFinishResponse(FinishResponse::Builder &b, - const Vamp::HostExt::ProcessResponse &pr, + buildFinishResponse(piper::FinishResponse::Builder &b, + const FinishResponse &pr, const PluginHandleMapper &pmapper) { b.setHandle(pmapper.pluginToHandle(pr.plugin)); @@ -716,8 +719,8 @@ } static void - readFinishResponse(Vamp::HostExt::ProcessResponse &pr, - const FinishResponse::Reader &r, + readFinishResponse(FinishResponse &pr, + const piper::FinishResponse::Reader &r, const PluginHandleMapper &pmapper) { auto h = r.getHandle(); @@ -727,13 +730,13 @@ } static void - buildRpcRequest_List(RpcRequest::Builder &b) { + buildRpcRequest_List(piper::RpcRequest::Builder &b) { b.getRequest().initList(); } static void - buildRpcResponse_List(RpcResponse::Builder &b, - const Vamp::HostExt::ListResponse &resp) { + buildRpcResponse_List(piper::RpcResponse::Builder &b, + const ListResponse &resp) { auto r = b.getResponse().initList(); auto p = r.initAvailable(resp.available.size()); @@ -744,15 +747,15 @@ } static void - buildRpcRequest_Load(RpcRequest::Builder &b, - const Vamp::HostExt::LoadRequest &req) { + buildRpcRequest_Load(piper::RpcRequest::Builder &b, + const LoadRequest &req) { auto u = b.getRequest().initLoad(); buildLoadRequest(u, req); } static void - buildRpcResponse_Load(RpcResponse::Builder &b, - const Vamp::HostExt::LoadResponse &resp, + buildRpcResponse_Load(piper::RpcResponse::Builder &b, + const LoadResponse &resp, const PluginHandleMapper &pmapper) { if (resp.plugin) { @@ -764,16 +767,16 @@ } static void - buildRpcRequest_Configure(RpcRequest::Builder &b, - const Vamp::HostExt::ConfigurationRequest &cr, + buildRpcRequest_Configure(piper::RpcRequest::Builder &b, + const ConfigurationRequest &cr, const PluginHandleMapper &pmapper) { auto u = b.getRequest().initConfigure(); buildConfigurationRequest(u, cr, pmapper); } static void - buildRpcResponse_Configure(RpcResponse::Builder &b, - const Vamp::HostExt::ConfigurationResponse &cr, + buildRpcResponse_Configure(piper::RpcResponse::Builder &b, + const ConfigurationResponse &cr, const PluginHandleMapper &pmapper) { if (!cr.outputs.empty()) { @@ -786,16 +789,16 @@ } static void - buildRpcRequest_Process(RpcRequest::Builder &b, - const Vamp::HostExt::ProcessRequest &pr, + buildRpcRequest_Process(piper::RpcRequest::Builder &b, + const ProcessRequest &pr, const PluginHandleMapper &pmapper) { auto u = b.getRequest().initProcess(); buildProcessRequest(u, pr, pmapper); } static void - buildRpcResponse_Process(RpcResponse::Builder &b, - const Vamp::HostExt::ProcessResponse &pr, + buildRpcResponse_Process(piper::RpcResponse::Builder &b, + const ProcessResponse &pr, const PluginHandleMapper &pmapper) { auto u = b.getResponse().initProcess(); @@ -803,8 +806,8 @@ } static void - buildRpcRequest_Finish(RpcRequest::Builder &b, - const Vamp::HostExt::FinishRequest &req, + buildRpcRequest_Finish(piper::RpcRequest::Builder &b, + const FinishRequest &req, const PluginHandleMapper &pmapper) { auto u = b.getRequest().initFinish(); @@ -812,8 +815,8 @@ } static void - buildRpcResponse_Finish(RpcResponse::Builder &b, - const Vamp::HostExt::ProcessResponse &pr, + buildRpcResponse_Finish(piper::RpcResponse::Builder &b, + const FinishResponse &pr, const PluginHandleMapper &pmapper) { auto u = b.getResponse().initFinish(); @@ -821,7 +824,7 @@ } static void - buildRpcResponse_Error(RpcResponse::Builder &b, + buildRpcResponse_Error(piper::RpcResponse::Builder &b, const std::string &errorText, RRType responseType) { @@ -848,7 +851,7 @@ } static void - buildRpcResponse_Exception(RpcResponse::Builder &b, + buildRpcResponse_Exception(piper::RpcResponse::Builder &b, const std::exception &e, RRType responseType) { @@ -856,36 +859,36 @@ } static RRType - getRequestResponseType(const RpcRequest::Reader &r) { + getRequestResponseType(const piper::RpcRequest::Reader &r) { switch (r.getRequest().which()) { - case RpcRequest::Request::Which::LIST: + case piper::RpcRequest::Request::Which::LIST: return RRType::List; - case RpcRequest::Request::Which::LOAD: + case piper::RpcRequest::Request::Which::LOAD: return RRType::Load; - case RpcRequest::Request::Which::CONFIGURE: + case piper::RpcRequest::Request::Which::CONFIGURE: return RRType::Configure; - case RpcRequest::Request::Which::PROCESS: + case piper::RpcRequest::Request::Which::PROCESS: return RRType::Process; - case RpcRequest::Request::Which::FINISH: + case piper::RpcRequest::Request::Which::FINISH: return RRType::Finish; } return RRType::NotValid; } static RRType - getRequestResponseType(const RpcResponse::Reader &r) { + getRequestResponseType(const piper::RpcResponse::Reader &r) { switch (r.getResponse().which()) { - case RpcResponse::Response::Which::ERROR: + case piper::RpcResponse::Response::Which::ERROR: return RRType::NotValid; //!!! or error type? test this - case RpcResponse::Response::Which::LIST: + case piper::RpcResponse::Response::Which::LIST: return RRType::List; - case RpcResponse::Response::Which::LOAD: + case piper::RpcResponse::Response::Which::LOAD: return RRType::Load; - case RpcResponse::Response::Which::CONFIGURE: + case piper::RpcResponse::Response::Which::CONFIGURE: return RRType::Configure; - case RpcResponse::Response::Which::PROCESS: + case piper::RpcResponse::Response::Which::PROCESS: return RRType::Process; - case RpcResponse::Response::Which::FINISH: + case piper::RpcResponse::Response::Which::FINISH: return RRType::Finish; } return RRType::NotValid; @@ -894,7 +897,7 @@ static void readRpcResponse_Error(int &code, std::string &message, - const RpcResponse::Reader &r) { + const piper::RpcResponse::Reader &r) { if (getRequestResponseType(r) != RRType::NotValid) { throw std::logic_error("not an error response"); } @@ -903,15 +906,15 @@ } static void - readRpcRequest_List(const RpcRequest::Reader &r) { + readRpcRequest_List(const piper::RpcRequest::Reader &r) { if (getRequestResponseType(r) != RRType::List) { throw std::logic_error("not a list request"); } } static void - readRpcResponse_List(Vamp::HostExt::ListResponse &resp, - const RpcResponse::Reader &r) { + readRpcResponse_List(ListResponse &resp, + const piper::RpcResponse::Reader &r) { if (getRequestResponseType(r) != RRType::List) { throw std::logic_error("not a list response"); } @@ -919,8 +922,8 @@ } static void - readRpcRequest_Load(Vamp::HostExt::LoadRequest &req, - const RpcRequest::Reader &r) { + readRpcRequest_Load(LoadRequest &req, + const piper::RpcRequest::Reader &r) { if (getRequestResponseType(r) != RRType::Load) { throw std::logic_error("not a load request"); } @@ -928,8 +931,8 @@ } static void - readRpcResponse_Load(Vamp::HostExt::LoadResponse &resp, - const RpcResponse::Reader &r, + readRpcResponse_Load(LoadResponse &resp, + const piper::RpcResponse::Reader &r, const PluginHandleMapper &pmapper) { if (getRequestResponseType(r) != RRType::Load) { throw std::logic_error("not a load response"); @@ -939,8 +942,8 @@ } static void - readRpcRequest_Configure(Vamp::HostExt::ConfigurationRequest &req, - const RpcRequest::Reader &r, + readRpcRequest_Configure(ConfigurationRequest &req, + const piper::RpcRequest::Reader &r, const PluginHandleMapper &pmapper) { if (getRequestResponseType(r) != RRType::Configure) { throw std::logic_error("not a configuration request"); @@ -949,8 +952,8 @@ } static void - readRpcResponse_Configure(Vamp::HostExt::ConfigurationResponse &resp, - const RpcResponse::Reader &r, + readRpcResponse_Configure(ConfigurationResponse &resp, + const piper::RpcResponse::Reader &r, const PluginHandleMapper &pmapper) { if (getRequestResponseType(r) != RRType::Configure) { throw std::logic_error("not a configuration response"); @@ -962,8 +965,8 @@ } static void - readRpcRequest_Process(Vamp::HostExt::ProcessRequest &req, - const RpcRequest::Reader &r, + readRpcRequest_Process(ProcessRequest &req, + const piper::RpcRequest::Reader &r, const PluginHandleMapper &pmapper) { if (getRequestResponseType(r) != RRType::Process) { throw std::logic_error("not a process request"); @@ -972,8 +975,8 @@ } static void - readRpcResponse_Process(Vamp::HostExt::ProcessResponse &resp, - const RpcResponse::Reader &r, + readRpcResponse_Process(ProcessResponse &resp, + const piper::RpcResponse::Reader &r, const PluginHandleMapper &pmapper) { if (getRequestResponseType(r) != RRType::Process) { throw std::logic_error("not a process response"); @@ -983,8 +986,8 @@ } static void - readRpcRequest_Finish(Vamp::HostExt::FinishRequest &req, - const RpcRequest::Reader &r, + readRpcRequest_Finish(FinishRequest &req, + const piper::RpcRequest::Reader &r, const PluginHandleMapper &pmapper) { if (getRequestResponseType(r) != RRType::Finish) { throw std::logic_error("not a finish request"); @@ -994,8 +997,8 @@ } static void - readRpcResponse_Finish(Vamp::HostExt::ProcessResponse &resp, - const RpcResponse::Reader &r, + readRpcResponse_Finish(FinishResponse &resp, + const piper::RpcResponse::Reader &r, const PluginHandleMapper &pmapper) { if (getRequestResponseType(r) != RRType::Finish) { throw std::logic_error("not a finish response");
--- a/vamp-client/CapnpRRClient.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-client/CapnpRRClient.h Thu Oct 13 18:05:35 2016 +0100 @@ -12,11 +12,11 @@ #include <capnp/serialize.h> -namespace piper { -namespace vampclient { +namespace piper_vamp { +namespace client { class CapnpRRClient : public PluginClient, - public Loader + public Loader { // unsigned to avoid undefined behaviour on possible wrap typedef uint32_t ReqId; @@ -56,7 +56,7 @@ // Loader methods: - Vamp::HostExt::ListResponse + ListResponse listPluginData() override { if (!m_transport->isOK()) { @@ -64,7 +64,7 @@ } capnp::MallocMessageBuilder message; - RpcRequest::Builder builder = message.initRoot<RpcRequest>(); + piper::RpcRequest::Builder builder = message.initRoot<piper::RpcRequest>(); VampnProto::buildRpcRequest_List(builder); ReqId id = getId(); builder.getId().setNumber(id); @@ -72,23 +72,23 @@ auto karr = call(message); capnp::FlatArrayMessageReader responseMessage(karr); - RpcResponse::Reader reader = responseMessage.getRoot<RpcResponse>(); + piper::RpcResponse::Reader reader = responseMessage.getRoot<piper::RpcResponse>(); - checkResponseType(reader, RpcResponse::Response::Which::LIST, id); + checkResponseType(reader, piper::RpcResponse::Response::Which::LIST, id); - Vamp::HostExt::ListResponse lr; + ListResponse lr; VampnProto::readListResponse(lr, reader.getResponse().getList()); return lr; } - Vamp::HostExt::LoadResponse - loadPlugin(const Vamp::HostExt::LoadRequest &req) override { + LoadResponse + loadPlugin(const LoadRequest &req) override { if (!m_transport->isOK()) { throw std::runtime_error("Piper server failed to start"); } - Vamp::HostExt::LoadResponse resp; + LoadResponse resp; PluginHandleMapper::Handle handle = serverLoad(req.pluginKey, req.inputSampleRate, req.adapterFlags, @@ -113,18 +113,18 @@ virtual Vamp::Plugin::OutputList configure(PluginStub *plugin, - Vamp::HostExt::PluginConfiguration config) override { + PluginConfiguration config) override { if (!m_transport->isOK()) { throw std::runtime_error("Piper server failed to start"); } - Vamp::HostExt::ConfigurationRequest request; + ConfigurationRequest request; request.plugin = plugin; request.configuration = config; capnp::MallocMessageBuilder message; - RpcRequest::Builder builder = message.initRoot<RpcRequest>(); + piper::RpcRequest::Builder builder = message.initRoot<piper::RpcRequest>(); VampnProto::buildRpcRequest_Configure(builder, request, m_mapper); ReqId id = getId(); @@ -133,13 +133,13 @@ auto karr = call(message); capnp::FlatArrayMessageReader responseMessage(karr); - RpcResponse::Reader reader = responseMessage.getRoot<RpcResponse>(); + piper::RpcResponse::Reader reader = responseMessage.getRoot<piper::RpcResponse>(); //!!! handle (explicit) error case - checkResponseType(reader, RpcResponse::Response::Which::CONFIGURE, id); + checkResponseType(reader, piper::RpcResponse::Response::Which::CONFIGURE, id); - Vamp::HostExt::ConfigurationResponse cr; + ConfigurationResponse cr; VampnProto::readConfigurationResponse(cr, reader.getResponse().getConfigure(), m_mapper); @@ -157,13 +157,13 @@ throw std::runtime_error("Piper server failed to start"); } - Vamp::HostExt::ProcessRequest request; + ProcessRequest request; request.plugin = plugin; request.inputBuffers = inputBuffers; request.timestamp = timestamp; capnp::MallocMessageBuilder message; - RpcRequest::Builder builder = message.initRoot<RpcRequest>(); + piper::RpcRequest::Builder builder = message.initRoot<piper::RpcRequest>(); VampnProto::buildRpcRequest_Process(builder, request, m_mapper); ReqId id = getId(); builder.getId().setNumber(id); @@ -171,13 +171,13 @@ auto karr = call(message); capnp::FlatArrayMessageReader responseMessage(karr); - RpcResponse::Reader reader = responseMessage.getRoot<RpcResponse>(); + piper::RpcResponse::Reader reader = responseMessage.getRoot<piper::RpcResponse>(); //!!! handle (explicit) error case - checkResponseType(reader, RpcResponse::Response::Which::PROCESS, id); + checkResponseType(reader, piper::RpcResponse::Response::Which::PROCESS, id); - Vamp::HostExt::ProcessResponse pr; + ProcessResponse pr; VampnProto::readProcessResponse(pr, reader.getResponse().getProcess(), m_mapper); @@ -192,11 +192,11 @@ throw std::runtime_error("Piper server failed to start"); } - Vamp::HostExt::FinishRequest request; + FinishRequest request; request.plugin = plugin; capnp::MallocMessageBuilder message; - RpcRequest::Builder builder = message.initRoot<RpcRequest>(); + piper::RpcRequest::Builder builder = message.initRoot<piper::RpcRequest>(); VampnProto::buildRpcRequest_Finish(builder, request, m_mapper); ReqId id = getId(); @@ -205,13 +205,13 @@ auto karr = call(message); capnp::FlatArrayMessageReader responseMessage(karr); - RpcResponse::Reader reader = responseMessage.getRoot<RpcResponse>(); + piper::RpcResponse::Reader reader = responseMessage.getRoot<piper::RpcResponse>(); //!!! handle (explicit) error case - checkResponseType(reader, RpcResponse::Response::Which::FINISH, id); + checkResponseType(reader, piper::RpcResponse::Response::Which::FINISH, id); - Vamp::HostExt::ProcessResponse pr; + FinishResponse pr; VampnProto::readFinishResponse(pr, reader.getResponse().getFinish(), m_mapper); @@ -226,7 +226,7 @@ virtual void reset(PluginStub *plugin, - Vamp::HostExt::PluginConfiguration config) override { + PluginConfiguration config) override { // Reload the plugin on the server side, and configure it as requested @@ -238,8 +238,8 @@ (void)finish(plugin); // server-side unload } - Vamp::HostExt::PluginStaticData psd; - Vamp::HostExt::PluginConfiguration defaultConfig; + PluginStaticData psd; + PluginConfiguration defaultConfig; PluginHandleMapper::Handle handle = serverLoad(plugin->getPluginKey(), plugin->getInputSampleRate(), @@ -272,8 +272,8 @@ } void - checkResponseType(const RpcResponse::Reader &r, - RpcResponse::Response::Which type, + checkResponseType(const piper::RpcResponse::Reader &r, + piper::RpcResponse::Response::Which type, ReqId id) { if (r.getResponse().which() != type) { @@ -294,16 +294,16 @@ PluginHandleMapper::Handle serverLoad(std::string key, float inputSampleRate, int adapterFlags, - Vamp::HostExt::PluginStaticData &psd, - Vamp::HostExt::PluginConfiguration &defaultConfig) { + PluginStaticData &psd, + PluginConfiguration &defaultConfig) { - Vamp::HostExt::LoadRequest request; + LoadRequest request; request.pluginKey = key; request.inputSampleRate = inputSampleRate; request.adapterFlags = adapterFlags; capnp::MallocMessageBuilder message; - RpcRequest::Builder builder = message.initRoot<RpcRequest>(); + piper::RpcRequest::Builder builder = message.initRoot<piper::RpcRequest>(); VampnProto::buildRpcRequest_Load(builder, request); ReqId id = getId(); @@ -315,13 +315,13 @@ //!!! (from another thread) capnp::FlatArrayMessageReader responseMessage(karr); - RpcResponse::Reader reader = responseMessage.getRoot<RpcResponse>(); + piper::RpcResponse::Reader reader = responseMessage.getRoot<piper::RpcResponse>(); //!!! handle (explicit) error case - checkResponseType(reader, RpcResponse::Response::Which::LOAD, id); + checkResponseType(reader, piper::RpcResponse::Response::Which::LOAD, id); - const LoadResponse::Reader &lr = reader.getResponse().getLoad(); + const piper::LoadResponse::Reader &lr = reader.getResponse().getLoad(); VampnProto::readExtractorStaticData(psd, lr.getStaticData()); VampnProto::readConfiguration(defaultConfig, lr.getDefaultConfiguration()); return lr.getHandle();
--- a/vamp-client/Loader.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-client/Loader.h Thu Oct 13 18:05:35 2016 +0100 @@ -2,21 +2,16 @@ #ifndef PIPER_LOADER_H #define PIPER_LOADER_H -#include <vamp-hostsdk/RequestResponse.h> +#include "vamp-support/RequestResponse.h" -namespace piper { -namespace vampclient { +namespace piper_vamp { +namespace client { class Loader { public: - virtual - Vamp::HostExt::ListResponse - listPluginData() = 0; - - virtual - Vamp::HostExt::LoadResponse - loadPlugin(const Vamp::HostExt::LoadRequest &) = 0; + virtual ListResponse listPluginData() = 0; + virtual LoadResponse loadPlugin(const LoadRequest &) = 0; }; }
--- a/vamp-client/PluginClient.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-client/PluginClient.h Thu Oct 13 18:05:35 2016 +0100 @@ -2,10 +2,10 @@ #ifndef PIPER_PLUGIN_CLIENT_H #define PIPER_PLUGIN_CLIENT_H -#include <vamp-hostsdk/PluginConfiguration.h> +#include "vamp-support/PluginConfiguration.h" -namespace piper { -namespace vampclient { +namespace piper_vamp { +namespace client { class PluginStub; @@ -15,7 +15,7 @@ virtual Vamp::Plugin::OutputList configure(PluginStub *plugin, - Vamp::HostExt::PluginConfiguration config) = 0; + PluginConfiguration config) = 0; virtual Vamp::Plugin::FeatureSet @@ -29,8 +29,7 @@ virtual void - reset(PluginStub *plugin, - Vamp::HostExt::PluginConfiguration config) = 0; + reset(PluginStub *plugin, PluginConfiguration config) = 0; }; }
--- a/vamp-client/PluginStub.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-client/PluginStub.h Thu Oct 13 18:05:35 2016 +0100 @@ -4,15 +4,16 @@ #include <vamp-hostsdk/Plugin.h> #include <vamp-hostsdk/PluginLoader.h> -#include <vamp-hostsdk/PluginStaticData.h> -#include <vamp-hostsdk/PluginConfiguration.h> + +#include "vamp-support/PluginStaticData.h" +#include "vamp-support/PluginConfiguration.h" #include <cstdint> #include "PluginClient.h" -namespace piper { -namespace vampclient { +namespace piper_vamp { +namespace client { class PluginStub : public Vamp::Plugin { @@ -25,8 +26,8 @@ std::string pluginKey, float inputSampleRate, int adapterFlags, - Vamp::HostExt::PluginStaticData psd, - Vamp::HostExt::PluginConfiguration defaultConfig) : + PluginStaticData psd, + PluginConfiguration defaultConfig) : Plugin(inputSampleRate), m_client(client), m_key(pluginKey), @@ -230,10 +231,10 @@ std::string m_key; int m_adapterFlags; State m_state; - Vamp::HostExt::PluginStaticData m_psd; + PluginStaticData m_psd; OutputList m_outputs; - Vamp::HostExt::PluginConfiguration m_defaultConfig; - Vamp::HostExt::PluginConfiguration m_config; + PluginConfiguration m_defaultConfig; + PluginConfiguration m_config; }; }
--- a/vamp-client/ProcessQtTransport.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-client/ProcessQtTransport.h Thu Oct 13 18:05:35 2016 +0100 @@ -9,8 +9,8 @@ #include <iostream> -namespace piper { -namespace vampclient { +namespace piper_vamp { +namespace client { class ProcessQtTransport : public SynchronousTransport {
--- a/vamp-client/SynchronousTransport.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-client/SynchronousTransport.h Thu Oct 13 18:05:35 2016 +0100 @@ -5,8 +5,8 @@ #include <vector> #include <cstdlib> -namespace piper { -namespace vampclient { +namespace piper_vamp { +namespace client { class MessageCompletenessChecker // interface {
--- a/vamp-client/client.cpp Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-client/client.cpp Thu Oct 13 18:05:35 2016 +0100 @@ -9,20 +9,20 @@ int main(int, char **) { - piper::vampclient::ProcessQtTransport transport("../bin/piper-vamp-server"); - piper::vampclient::CapnpRRClient client(&transport); + piper_vamp::client::ProcessQtTransport transport("../bin/piper-vamp-server"); + piper_vamp::client::CapnpRRClient client(&transport); - Vamp::HostExt::ListResponse lr = client.listPluginData(); + piper_vamp::ListResponse lr = client.listPluginData(); cerr << "Plugins available:" << endl; int i = 1; for (const auto &p: lr.available) { cerr << i++ << ". [" << p.pluginKey << "] " << p.basic.name << endl; } - Vamp::HostExt::LoadRequest req; + piper_vamp::LoadRequest req; req.pluginKey = "vamp-example-plugins:zerocrossing"; req.inputSampleRate = 16; - Vamp::HostExt::LoadResponse resp = client.loadPlugin(req); + piper_vamp::LoadResponse resp = client.loadPlugin(req); Vamp::Plugin *plugin = resp.plugin; if (!plugin->initialise(1, 4, 4)) {
--- a/vamp-json/VampJson.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-json/VampJson.h Thu Oct 13 18:05:35 2016 +0100 @@ -44,15 +44,16 @@ #include <vamp-hostsdk/Plugin.h> #include <vamp-hostsdk/PluginLoader.h> -#include <vamp-hostsdk/PluginStaticData.h> -#include <vamp-hostsdk/PluginConfiguration.h> -#include <vamp-hostsdk/RequestResponse.h> + +#include "vamp-support/PluginStaticData.h" +#include "vamp-support/PluginConfiguration.h" +#include "vamp-support/RequestResponse.h" #include "vamp-support/PluginHandleMapper.h" #include "vamp-support/PluginOutputIdMapper.h" #include "vamp-support/RequestResponseType.h" -namespace piper { +namespace piper_vamp { /** * Convert the structures laid out in the Vamp SDK classes into JSON @@ -534,7 +535,7 @@ } static json11::Json - fromPluginStaticData(const Vamp::HostExt::PluginStaticData &d) { + fromPluginStaticData(const PluginStaticData &d) { json11::Json::object jo; jo["key"] = d.pluginKey; @@ -570,7 +571,7 @@ return json11::Json(jo); } - static Vamp::HostExt::PluginStaticData + static PluginStaticData toPluginStaticData(json11::Json j, std::string &err) { if (!j.has_shape({ @@ -622,7 +623,7 @@ } else { - Vamp::HostExt::PluginStaticData psd; + PluginStaticData psd; psd.pluginKey = j["key"].string_value(); @@ -662,7 +663,7 @@ if (failed(err)) return {}; for (const auto &bo : j["basicOutputInfo"].array_items()) { - Vamp::HostExt::PluginStaticData::Basic b; + PluginStaticData::Basic b; toBasicDescriptor(bo, b, err); if (failed(err)) return {}; psd.basicOutputInfo.push_back(b); @@ -676,7 +677,7 @@ } static json11::Json - fromPluginConfiguration(const Vamp::HostExt::PluginConfiguration &c) { + fromPluginConfiguration(const PluginConfiguration &c) { json11::Json::object jo; @@ -697,7 +698,7 @@ return json11::Json(jo); } - static Vamp::HostExt::PluginConfiguration + static PluginConfiguration toPluginConfiguration(json11::Json j, std::string &err) { if (!j.has_shape({ @@ -727,7 +728,7 @@ return {}; } - Vamp::HostExt::PluginConfiguration config; + PluginConfiguration config; config.channelCount = j["channelCount"].number_value(); config.stepSize = j["stepSize"].number_value(); @@ -800,7 +801,7 @@ } static json11::Json - fromLoadRequest(const Vamp::HostExt::LoadRequest &req) { + fromLoadRequest(const LoadRequest &req) { json11::Json::object jo; jo["key"] = req.pluginKey; @@ -809,7 +810,7 @@ return json11::Json(jo); } - static Vamp::HostExt::LoadRequest + static LoadRequest toLoadRequest(json11::Json j, std::string &err) { if (!j.has_shape({ @@ -819,7 +820,7 @@ return {}; } - Vamp::HostExt::LoadRequest req; + LoadRequest req; req.pluginKey = j["key"].string_value(); req.inputSampleRate = j["inputSampleRate"].number_value(); if (!j["adapterFlags"].is_null()) { @@ -830,7 +831,7 @@ } static json11::Json - fromLoadResponse(const Vamp::HostExt::LoadResponse &resp, + fromLoadResponse(const LoadResponse &resp, const PluginHandleMapper &pmapper) { json11::Json::object jo; @@ -841,7 +842,7 @@ return json11::Json(jo); } - static Vamp::HostExt::LoadResponse + static LoadResponse toLoadResponse(json11::Json j, const PluginHandleMapper &pmapper, std::string &err) { @@ -853,7 +854,7 @@ return {}; } - Vamp::HostExt::LoadResponse resp; + LoadResponse resp; resp.plugin = pmapper.handleToPlugin(j["handle"].int_value()); resp.staticData = toPluginStaticData(j["staticData"], err); if (failed(err)) return {}; @@ -864,7 +865,7 @@ } static json11::Json - fromConfigurationRequest(const Vamp::HostExt::ConfigurationRequest &cr, + fromConfigurationRequest(const ConfigurationRequest &cr, const PluginHandleMapper &pmapper) { json11::Json::object jo; @@ -875,7 +876,7 @@ return json11::Json(jo); } - static Vamp::HostExt::ConfigurationRequest + static ConfigurationRequest toConfigurationRequest(json11::Json j, const PluginHandleMapper &pmapper, std::string &err) { @@ -886,7 +887,7 @@ return {}; } - Vamp::HostExt::ConfigurationRequest cr; + ConfigurationRequest cr; cr.plugin = pmapper.handleToPlugin(j["handle"].int_value()); cr.configuration = toPluginConfiguration(j["configuration"], err); if (failed(err)) return {}; @@ -894,7 +895,7 @@ } static json11::Json - fromConfigurationResponse(const Vamp::HostExt::ConfigurationResponse &cr, + fromConfigurationResponse(const ConfigurationResponse &cr, const PluginHandleMapper &pmapper) { json11::Json::object jo; @@ -910,11 +911,11 @@ return json11::Json(jo); } - static Vamp::HostExt::ConfigurationResponse + static ConfigurationResponse toConfigurationResponse(json11::Json j, const PluginHandleMapper &pmapper, std::string &err) { - Vamp::HostExt::ConfigurationResponse cr; + ConfigurationResponse cr; cr.plugin = pmapper.handleToPlugin(j["handle"].int_value()); @@ -932,7 +933,7 @@ } static json11::Json - fromProcessRequest(const Vamp::HostExt::ProcessRequest &r, + fromProcessRequest(const ProcessRequest &r, const PluginHandleMapper &pmapper, BufferSerialisation serialisation) { @@ -958,7 +959,7 @@ return json11::Json(jo); } - static Vamp::HostExt::ProcessRequest + static ProcessRequest toProcessRequest(json11::Json j, const PluginHandleMapper &pmapper, BufferSerialisation &serialisation, std::string &err) { @@ -979,7 +980,7 @@ return {}; } - Vamp::HostExt::ProcessRequest r; + ProcessRequest r; r.plugin = pmapper.handleToPlugin(j["handle"].int_value()); r.timestamp = toRealTime(input["timestamp"], err); @@ -1060,7 +1061,7 @@ } static json11::Json - fromRpcResponse_List(const Vamp::HostExt::ListResponse &resp, + fromRpcResponse_List(const ListResponse &resp, const json11::Json &id) { json11::Json::object jo; @@ -1080,7 +1081,7 @@ } static json11::Json - fromRpcRequest_Load(const Vamp::HostExt::LoadRequest &req, + fromRpcRequest_Load(const LoadRequest &req, const json11::Json &id) { json11::Json::object jo; @@ -1093,7 +1094,7 @@ } static json11::Json - fromRpcResponse_Load(const Vamp::HostExt::LoadResponse &resp, + fromRpcResponse_Load(const LoadResponse &resp, const PluginHandleMapper &pmapper, const json11::Json &id) { @@ -1113,7 +1114,7 @@ } static json11::Json - fromRpcRequest_Configure(const Vamp::HostExt::ConfigurationRequest &req, + fromRpcRequest_Configure(const ConfigurationRequest &req, const PluginHandleMapper &pmapper, const json11::Json &id) { @@ -1127,7 +1128,7 @@ } static json11::Json - fromRpcResponse_Configure(const Vamp::HostExt::ConfigurationResponse &resp, + fromRpcResponse_Configure(const ConfigurationResponse &resp, const PluginHandleMapper &pmapper, const json11::Json &id) { @@ -1147,7 +1148,7 @@ } static json11::Json - fromRpcRequest_Process(const Vamp::HostExt::ProcessRequest &req, + fromRpcRequest_Process(const ProcessRequest &req, const PluginHandleMapper &pmapper, BufferSerialisation serialisation, const json11::Json &id) { @@ -1162,7 +1163,7 @@ } static json11::Json - fromRpcResponse_Process(const Vamp::HostExt::ProcessResponse &resp, + fromRpcResponse_Process(const ProcessResponse &resp, const PluginHandleMapper &pmapper, BufferSerialisation serialisation, const json11::Json &id) { @@ -1182,7 +1183,7 @@ } static json11::Json - fromRpcRequest_Finish(const Vamp::HostExt::FinishRequest &req, + fromRpcRequest_Finish(const FinishRequest &req, const PluginHandleMapper &pmapper, const json11::Json &id) { @@ -1199,7 +1200,7 @@ } static json11::Json - fromRpcResponse_Finish(const Vamp::HostExt::ProcessResponse &resp, + fromRpcResponse_Finish(const FinishResponse &resp, const PluginHandleMapper &pmapper, BufferSerialisation serialisation, const json11::Json &id) { @@ -1273,10 +1274,10 @@ checkTypeField(j, "list", err); } - static Vamp::HostExt::ListResponse + static ListResponse toRpcResponse_List(json11::Json j, std::string &err) { - Vamp::HostExt::ListResponse resp; + ListResponse resp; if (successful(j, err) && !failed(err)) { for (const auto &a: j["result"]["available"].array_items()) { resp.available.push_back(toPluginStaticData(a, err)); @@ -1287,7 +1288,7 @@ return resp; } - static Vamp::HostExt::LoadRequest + static LoadRequest toRpcRequest_Load(json11::Json j, std::string &err) { checkTypeField(j, "load", err); @@ -1295,19 +1296,19 @@ return toLoadRequest(j["params"], err); } - static Vamp::HostExt::LoadResponse + static LoadResponse toRpcResponse_Load(json11::Json j, const PluginHandleMapper &pmapper, std::string &err) { - Vamp::HostExt::LoadResponse resp; + LoadResponse resp; if (successful(j, err) && !failed(err)) { resp = toLoadResponse(j["result"], pmapper, err); } return resp; } - static Vamp::HostExt::ConfigurationRequest + static ConfigurationRequest toRpcRequest_Configure(json11::Json j, const PluginHandleMapper &pmapper, std::string &err) { @@ -1317,19 +1318,19 @@ return toConfigurationRequest(j["params"], pmapper, err); } - static Vamp::HostExt::ConfigurationResponse + static ConfigurationResponse toRpcResponse_Configure(json11::Json j, const PluginHandleMapper &pmapper, std::string &err) { - Vamp::HostExt::ConfigurationResponse resp; + ConfigurationResponse resp; if (successful(j, err) && !failed(err)) { resp = toConfigurationResponse(j["result"], pmapper, err); } return resp; } - static Vamp::HostExt::ProcessRequest + static ProcessRequest toRpcRequest_Process(json11::Json j, const PluginHandleMapper &pmapper, BufferSerialisation &serialisation, std::string &err) { @@ -1338,12 +1339,12 @@ return toProcessRequest(j["params"], pmapper, serialisation, err); } - static Vamp::HostExt::ProcessResponse + static ProcessResponse toRpcResponse_Process(json11::Json j, const PluginHandleMapper &pmapper, BufferSerialisation &serialisation, std::string &err) { - Vamp::HostExt::ProcessResponse resp; + ProcessResponse resp; if (successful(j, err) && !failed(err)) { auto jc = j["result"]; auto h = jc["handle"].int_value(); @@ -1355,24 +1356,24 @@ return resp; } - static Vamp::HostExt::FinishRequest + static FinishRequest toRpcRequest_Finish(json11::Json j, const PluginHandleMapper &pmapper, std::string &err) { checkTypeField(j, "finish", err); if (failed(err)) return {}; - Vamp::HostExt::FinishRequest req; + FinishRequest req; req.plugin = pmapper.handleToPlugin (j["params"]["handle"].int_value()); return req; } - static Vamp::HostExt::ProcessResponse + static FinishResponse toRpcResponse_Finish(json11::Json j, - const PluginHandleMapper &pmapper, - BufferSerialisation &serialisation, std::string &err) { + const PluginHandleMapper &pmapper, + BufferSerialisation &serialisation, std::string &err) { - Vamp::HostExt::ProcessResponse resp; + FinishResponse resp; if (successful(j, err) && !failed(err)) { auto jc = j["result"]; auto h = jc["handle"].int_value();
--- a/vamp-server/convert.cpp Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-server/convert.cpp Thu Oct 13 18:05:35 2016 +0100 @@ -12,7 +12,7 @@ using namespace std; using namespace json11; -using namespace piper; +using namespace piper_vamp; void usage() { @@ -117,13 +117,13 @@ int number; string tag; switch (r.getId().which()) { - case RpcRequest::Id::Which::NUMBER: + case piper::RpcRequest::Id::Which::NUMBER: number = r.getId().getNumber(); return { RequestOrResponse::RpcId::Number, number, "" }; - case RpcRequest::Id::Which::TAG: + case piper::RpcRequest::Id::Which::TAG: tag = r.getId().getTag(); return { RequestOrResponse::RpcId::Tag, 0, tag }; - case RpcRequest::Id::Which::NONE: + case piper::RpcRequest::Id::Which::NONE: return { RequestOrResponse::RpcId::Absent, 0, "" }; } return {}; @@ -334,8 +334,8 @@ RequestOrResponse rr; rr.direction = RequestOrResponse::Request; - ::capnp::InputStreamMessageReader message(buffered); - RpcRequest::Reader reader = message.getRoot<RpcRequest>(); + capnp::InputStreamMessageReader message(buffered); + piper::RpcRequest::Reader reader = message.getRoot<piper::RpcRequest>(); rr.type = VampnProto::getRequestResponseType(reader); rr.id = readCapnpId(reader); @@ -368,8 +368,8 @@ void writeRequestCapnp(RequestOrResponse &rr) { - ::capnp::MallocMessageBuilder message; - RpcRequest::Builder builder = message.initRoot<RpcRequest>(); + capnp::MallocMessageBuilder message; + piper::RpcRequest::Builder builder = message.initRoot<piper::RpcRequest>(); buildCapnpId(builder, rr.id); @@ -404,8 +404,8 @@ RequestOrResponse rr; rr.direction = RequestOrResponse::Response; - ::capnp::InputStreamMessageReader message(buffered); - RpcResponse::Reader reader = message.getRoot<RpcResponse>(); + capnp::InputStreamMessageReader message(buffered); + piper::RpcResponse::Reader reader = message.getRoot<piper::RpcResponse>(); rr.type = VampnProto::getRequestResponseType(reader); rr.success = true; @@ -444,8 +444,8 @@ void writeResponseCapnp(RequestOrResponse &rr) { - ::capnp::MallocMessageBuilder message; - RpcResponse::Builder builder = message.initRoot<RpcResponse>(); + capnp::MallocMessageBuilder message; + piper::RpcResponse::Builder builder = message.initRoot<piper::RpcResponse>(); buildCapnpId(builder, rr.id);
--- a/vamp-server/server.cpp Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-server/server.cpp Thu Oct 13 18:05:35 2016 +0100 @@ -2,6 +2,7 @@ #include "vamp-capnp/VampnProto.h" #include "vamp-support/RequestOrResponse.h" #include "vamp-support/CountingPluginHandleMapper.h" +#include "vamp-support/LoaderRequests.h" #include <iostream> #include <sstream> @@ -13,9 +14,8 @@ #include <set> using namespace std; -using namespace piper; +using namespace piper_vamp; using namespace Vamp; -using namespace Vamp::HostExt; void usage() { @@ -31,24 +31,24 @@ static CountingPluginHandleMapper mapper; -static RequestOrResponse::RpcId readId(const RpcRequest::Reader &r) +static RequestOrResponse::RpcId readId(const piper::RpcRequest::Reader &r) { int number; string tag; switch (r.getId().which()) { - case RpcRequest::Id::Which::NUMBER: + case piper::RpcRequest::Id::Which::NUMBER: number = r.getId().getNumber(); return { RequestOrResponse::RpcId::Number, number, "" }; - case RpcRequest::Id::Which::TAG: + case piper::RpcRequest::Id::Which::TAG: tag = r.getId().getTag(); return { RequestOrResponse::RpcId::Tag, 0, tag }; - case RpcRequest::Id::Which::NONE: + case piper::RpcRequest::Id::Which::NONE: return { RequestOrResponse::RpcId::Absent, 0, "" }; } return {}; } -static void buildId(RpcResponse::Builder &b, const RequestOrResponse::RpcId &id) +static void buildId(piper::RpcResponse::Builder &b, const RequestOrResponse::RpcId &id) { switch (id.type) { case RequestOrResponse::RpcId::Number: @@ -77,8 +77,8 @@ return rr; } - ::capnp::InputStreamMessageReader message(buffered); - RpcRequest::Reader reader = message.getRoot<RpcRequest>(); + capnp::InputStreamMessageReader message(buffered); + piper::RpcRequest::Reader reader = message.getRoot<piper::RpcRequest>(); rr.type = VampnProto::getRequestResponseType(reader); rr.id = readId(reader); @@ -111,8 +111,8 @@ void writeResponseCapnp(RequestOrResponse &rr) { - ::capnp::MallocMessageBuilder message; - RpcResponse::Builder builder = message.initRoot<RpcResponse>(); + capnp::MallocMessageBuilder message; + piper::RpcResponse::Builder builder = message.initRoot<piper::RpcResponse>(); buildId(builder, rr.id); @@ -150,8 +150,8 @@ void writeExceptionCapnp(const std::exception &e, RRType type) { - ::capnp::MallocMessageBuilder message; - RpcResponse::Builder builder = message.initRoot<RpcResponse>(); + capnp::MallocMessageBuilder message; + piper::RpcResponse::Builder builder = message.initRoot<piper::RpcResponse>(); VampnProto::buildRpcResponse_Exception(builder, e, type); writeMessageToFd(1, message); @@ -164,17 +164,15 @@ response.direction = RequestOrResponse::Response; response.type = request.type; - auto loader = PluginLoader::getInstance(); - switch (request.type) { case RRType::List: - response.listResponse = loader->listPluginData(); + response.listResponse = LoaderRequests().listPluginData(); response.success = true; break; case RRType::Load: - response.loadResponse = loader->loadPlugin(request.loadRequest); + response.loadResponse = LoaderRequests().loadPlugin(request.loadRequest); if (response.loadResponse.plugin != nullptr) { mapper.addPlugin(response.loadResponse.plugin); cerr << "loaded plugin, handle = " << mapper.pluginToHandle(response.loadResponse.plugin) << endl; @@ -190,7 +188,7 @@ throw runtime_error("plugin has already been configured"); } - response.configurationResponse = loader->configurePlugin(creq); + response.configurationResponse = LoaderRequests().configurePlugin(creq); if (!response.configurationResponse.outputs.empty()) { mapper.markConfigured
--- a/vamp-support/AssignedPluginHandleMapper.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-support/AssignedPluginHandleMapper.h Thu Oct 13 18:05:35 2016 +0100 @@ -43,7 +43,7 @@ #include <map> #include <iostream> -namespace piper { +namespace piper_vamp { class AssignedPluginHandleMapper : public PluginHandleMapper {
--- a/vamp-support/CountingPluginHandleMapper.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-support/CountingPluginHandleMapper.h Thu Oct 13 18:05:35 2016 +0100 @@ -42,7 +42,7 @@ #include <set> #include <map> -namespace piper { +namespace piper_vamp { class CountingPluginHandleMapper : public PluginHandleMapper {
--- a/vamp-support/DefaultPluginOutputIdMapper.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-support/DefaultPluginOutputIdMapper.h Thu Oct 13 18:05:35 2016 +0100 @@ -37,7 +37,7 @@ #include <vamp-hostsdk/Plugin.h> -namespace piper { +namespace piper_vamp { class DefaultPluginOutputIdMapper : public PluginOutputIdMapper {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vamp-support/LoaderRequests.h Thu Oct 13 18:05:35 2016 +0100 @@ -0,0 +1,134 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Piper C++ + + An API for audio analysis and feature extraction plugins. + + Centre for Digital Music, Queen Mary, University of London. + Copyright 2006-2016 Chris Cannam and QMUL. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR + ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the names of the Centre for + Digital Music; Queen Mary, University of London; and Chris Cannam + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in this Software without prior written + authorization. +*/ + +#ifndef PIPER_LOADER_REQUESTS_H +#define PIPER_LOADER_REQUESTS_H + +#include "PluginStaticData.h" +#include "PluginConfiguration.h" + +#include <vamp-hostsdk/PluginLoader.h> + +#include <map> +#include <string> + +namespace piper_vamp { + +class LoaderRequests +{ +public: + ListResponse + listPluginData() { + + auto loader = Vamp::HostExt::PluginLoader::getInstance(); + auto keys = loader->listPlugins(); + ListResponse response; + + for (std::string key: keys) { + Vamp::Plugin *p = loader->loadPlugin(key, 44100, 0); + if (!p) continue; + auto category = loader->getPluginCategory(key); + response.available.push_back + (PluginStaticData::fromPlugin(key, category, p)); + delete p; + } + + return response; + } + + LoadResponse + loadPlugin(LoadRequest req) { + + auto loader = Vamp::HostExt::PluginLoader::getInstance(); + + Vamp::Plugin *plugin = loader->loadPlugin(req.pluginKey, + req.inputSampleRate, + req.adapterFlags); + + LoadResponse response; + response.plugin = plugin; + if (!plugin) return response; + + response.plugin = plugin; + response.staticData = PluginStaticData::fromPlugin + (req.pluginKey, + loader->getPluginCategory(req.pluginKey), + plugin); + + int defaultChannels = 0; + if (plugin->getMinChannelCount() == plugin->getMaxChannelCount()) { + defaultChannels = plugin->getMinChannelCount(); + } + + response.defaultConfiguration = PluginConfiguration::fromPlugin + (plugin, + defaultChannels, + plugin->getPreferredStepSize(), + plugin->getPreferredBlockSize()); + + return response; + } + + ConfigurationResponse + configurePlugin(ConfigurationRequest req) { + + for (PluginConfiguration::ParameterMap::const_iterator i = + req.configuration.parameterValues.begin(); + i != req.configuration.parameterValues.end(); ++i) { + req.plugin->setParameter(i->first, i->second); + } + + if (req.configuration.currentProgram != "") { + req.plugin->selectProgram(req.configuration.currentProgram); + } + + ConfigurationResponse response; + + response.plugin = req.plugin; + + if (req.plugin->initialise(req.configuration.channelCount, + req.configuration.stepSize, + req.configuration.blockSize)) { + response.outputs = req.plugin->getOutputDescriptors(); + } + + return response; + } +}; + +} + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vamp-support/PluginConfiguration.h Thu Oct 13 18:05:35 2016 +0100 @@ -0,0 +1,100 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Piper C++ + + An API for audio analysis and feature extraction plugins. + + Centre for Digital Music, Queen Mary, University of London. + Copyright 2006-2016 Chris Cannam and QMUL. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR + ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the names of the Centre for + Digital Music; Queen Mary, University of London; and Chris Cannam + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in this Software without prior written + authorization. +*/ + +#ifndef PIPER_PLUGIN_CONFIGURATION_H +#define PIPER_PLUGIN_CONFIGURATION_H + +#include <vamp-hostsdk/Plugin.h> + +#include <map> +#include <string> + +namespace piper_vamp { + +/** + * \class PluginConfiguration + * + * PluginConfiguration is a structure bundling together data that + * affect the configuration of a plugin: parameter values, programs, + * and initialisation settings. Although an interactive Vamp plugin + * host may configure a plugin in stages, for example to take into + * account that a plugin's preferred step and block size may change + * when its parameters are changed, a batch host or a host supporting + * store and recall of configurations may wish to keep all + * configuration settings together. + */ +struct PluginConfiguration +{ + PluginConfiguration() : // invalid configuration by default + channelCount(0), stepSize(0), blockSize(0) { } + + int channelCount; + int stepSize; + int blockSize; + typedef std::map<std::string, float> ParameterMap; + ParameterMap parameterValues; + std::string currentProgram; + + static PluginConfiguration + fromPlugin(Vamp::Plugin *p, + int channelCount, + int stepSize, + int blockSize) { + + PluginConfiguration c; + + c.channelCount = channelCount; + c.stepSize = stepSize; + c.blockSize = blockSize; + + Vamp::PluginBase::ParameterList params = p->getParameterDescriptors(); + for (Vamp::PluginBase::ParameterList::const_iterator i = params.begin(); + i != params.end(); ++i) { + std::string pid = i->identifier; + c.parameterValues[pid] = p->getParameter(pid); + } + + if (!p->getPrograms().empty()) { + c.currentProgram = p->getCurrentProgram(); + } + + return c; + } +}; + +} + +#endif
--- a/vamp-support/PluginHandleMapper.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-support/PluginHandleMapper.h Thu Oct 13 18:05:35 2016 +0100 @@ -40,7 +40,7 @@ #include <vamp-hostsdk/Plugin.h> #include <memory> -namespace piper { +namespace piper_vamp { /** * Convert plugin pointers to handles within some scope defined by the
--- a/vamp-support/PluginOutputIdMapper.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-support/PluginOutputIdMapper.h Thu Oct 13 18:05:35 2016 +0100 @@ -40,7 +40,7 @@ #include <map> #include <string> -namespace piper { +namespace piper_vamp { class PluginOutputIdMapper {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vamp-support/PluginStaticData.h Thu Oct 13 18:05:35 2016 +0100 @@ -0,0 +1,119 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Piper C++ + + Centre for Digital Music, Queen Mary, University of London. + Copyright 2006-2016 Chris Cannam and QMUL. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR + ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the names of the Centre for + Digital Music; Queen Mary, University of London; and Chris Cannam + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in this Software without prior written + authorization. +*/ + +#ifndef PIPER_PLUGIN_STATIC_DATA_H +#define PIPER_PLUGIN_STATIC_DATA_H + +#include <vamp-hostsdk/Plugin.h> + +namespace piper_vamp { + +/** + * \class PluginStaticData + * + * PluginStaticData is a structure bundling together all the + * information about a plugin that cannot be changed by the plugin + * after it is loaded. That is, everything that does not depend on a + * parameter or initialisation setting. + * + * All of the information in here can be queried from other sources + * directly (notably the Vamp::Plugin class itself); this structure + * just pulls it together in one place and provides something that can + * be stored and recalled without having a Vamp::Plugin object to + * hand. + */ +struct PluginStaticData +{ +public: + struct Basic { + std::string identifier; + std::string name; + std::string description; + }; + typedef std::vector<Basic> BasicList; + + PluginStaticData() : // invalid static data by default + pluginVersion(0), minChannelCount(0), maxChannelCount(0), + inputDomain(Vamp::Plugin::TimeDomain) { } + + std::string pluginKey; + Basic basic; + std::string maker; + std::string copyright; + int pluginVersion; + std::vector<std::string> category; + int minChannelCount; + int maxChannelCount; + Vamp::PluginBase::ParameterList parameters; + Vamp::PluginBase::ProgramList programs; + Vamp::Plugin::InputDomain inputDomain; + BasicList basicOutputInfo; + + static PluginStaticData + fromPlugin(std::string pluginKey, + std::vector<std::string> category, + Vamp::Plugin *p) { + + PluginStaticData d; + d.pluginKey = pluginKey; + d.basic.identifier = p->getIdentifier(); + d.basic.name = p->getName(); + d.basic.description = p->getDescription(); + d.maker = p->getMaker(); + d.copyright = p->getCopyright(); + d.pluginVersion = p->getPluginVersion(); + d.category = category; + d.minChannelCount = p->getMinChannelCount(); + d.maxChannelCount = p->getMaxChannelCount(); + d.parameters = p->getParameterDescriptors(); + d.programs = p->getPrograms(); + d.inputDomain = p->getInputDomain(); + + Vamp::Plugin::OutputList outputs = p->getOutputDescriptors(); + for (Vamp::Plugin::OutputList::const_iterator i = outputs.begin(); + i != outputs.end(); ++i) { + Basic b; + b.identifier = i->identifier; + b.name = i->name; + b.description = i->description; + d.basicOutputInfo.push_back(b); + } + + return d; + } +}; + +} + +#endif
--- a/vamp-support/PreservingPluginHandleMapper.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-support/PreservingPluginHandleMapper.h Thu Oct 13 18:05:35 2016 +0100 @@ -40,7 +40,7 @@ #include <iostream> -namespace piper { +namespace piper_vamp { //!!! document -- this is a passthrough thing for a single plugin //!!! handle only, it does not use actually valid Plugin pointers at
--- a/vamp-support/PreservingPluginOutputIdMapper.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-support/PreservingPluginOutputIdMapper.h Thu Oct 13 18:05:35 2016 +0100 @@ -39,7 +39,7 @@ #include <iostream> -namespace piper { +namespace piper_vamp { //!!! document -- this is a passthrough thing that invents its //!!! numerical ids, they have no correspondence with any real plugin
--- a/vamp-support/RequestOrResponse.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-support/RequestOrResponse.h Thu Oct 13 18:05:35 2016 +0100 @@ -36,14 +36,13 @@ #define PIPER_REQUEST_OR_RESPONSE_H #include "RequestResponseType.h" - -#include <vamp-hostsdk/PluginStaticData.h> -#include <vamp-hostsdk/RequestResponse.h> +#include "PluginStaticData.h" +#include "RequestResponse.h" #include <string> #include <vector> -namespace piper { +namespace piper_vamp { class RequestOrResponse { @@ -71,15 +70,15 @@ std::string errorText; RpcId id; - Vamp::HostExt::ListResponse listResponse; - Vamp::HostExt::LoadRequest loadRequest; - Vamp::HostExt::LoadResponse loadResponse; - Vamp::HostExt::ConfigurationRequest configurationRequest; - Vamp::HostExt::ConfigurationResponse configurationResponse; - Vamp::HostExt::ProcessRequest processRequest; - Vamp::HostExt::ProcessResponse processResponse; - Vamp::HostExt::FinishRequest finishRequest; - Vamp::HostExt::ProcessResponse finishResponse; + ListResponse listResponse; + LoadRequest loadRequest; + LoadResponse loadResponse; + ConfigurationRequest configurationRequest; + ConfigurationResponse configurationResponse; + ProcessRequest processRequest; + ProcessResponse processResponse; + FinishRequest finishRequest; + FinishResponse finishResponse; }; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vamp-support/RequestResponse.h Thu Oct 13 18:05:35 2016 +0100 @@ -0,0 +1,281 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Piper C++ + + An API for audio analysis and feature extraction plugins. + + Centre for Digital Music, Queen Mary, University of London. + Copyright 2006-2016 Chris Cannam and QMUL. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR + ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the names of the Centre for + Digital Music; Queen Mary, University of London; and Chris Cannam + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in this Software without prior written + authorization. +*/ + +#ifndef PIPER_REQUEST_RESPONSE_H +#define PIPER_REQUEST_RESPONSE_H + +#include "PluginStaticData.h" +#include "PluginConfiguration.h" + +#include <map> +#include <string> + +namespace piper_vamp { + +/** + * \class ListRequest + * + * ListRequest is a structure containing the information needed to + * list plugins. Currently empty. + * + * \see ListResponse + */ +struct ListRequest +{ +}; + +/** + * \class ListResponse + * + * ListResponse is a structure containing the information returned by + * PluginLoader when asked to list static information about the + * available plugins. + * + * \see PluginStaticData + */ +struct ListResponse +{ + ListResponse() { } // empty by default + + std::vector<PluginStaticData> available; +}; + +/** + * \class LoadRequest + * + * LoadRequest is a structure containing the information necessary to + * load a plugin. When a request is made to load a plugin using a + * LoadRequest, the response is typically returned in a LoadResponse + * structure. + * + * \see LoadResponse + */ +struct LoadRequest +{ + LoadRequest() : // invalid request by default + inputSampleRate(0.f), + adapterFlags(0) { } + + /** + * PluginKey is a string type that is used to identify a plugin + * uniquely within the scope of "the current system". For further + * details \see Vamp::PluginLoader::PluginKey. + */ + typedef std::string PluginKey; + + /** + * The identifying key for the plugin to be loaded. + */ + PluginKey pluginKey; + + /** + * Sample rate to be passed to the plugin's constructor. + */ + float inputSampleRate; + + /** + * A bitwise OR of the values in the PluginLoader::AdapterFlags + * enumeration, indicating under which circumstances an adapter + * should be used to wrap the original plugin. If adapterFlags is + * 0, no optional adapters will be used. + * + * \see Vamp::PluginLoader::AdapterFlags + */ + int adapterFlags; +}; + +/** + * \class LoadResponse + * + * LoadResponse is a structure containing the information returned by + * PluginLoader when asked to load a plugin using a LoadRequest. + * + * If the plugin could not be loaded, the plugin field will be 0. + * + * The caller takes ownership of the plugin contained here, which + * should be deleted (using the standard C++ delete keyword) after + * use. + * + * \see LoadRequest + */ +struct LoadResponse +{ + LoadResponse() : // invalid (failed) response by default + plugin(0) { } + + /** + * A pointer to the loaded plugin, or 0 if loading failed. Caller + * takes ownership of the plugin and must delete it after use. + */ + Vamp::Plugin *plugin; + + /** + * The static data associated with the loaded plugin, that is, all + * information about it that does not depend on its configuration + * (parameters, programs, initialisation parameters). The contents + * of this structure are only valid if plugin is non-0. + * + * Much of the data in here is duplicated with the plugin itself. + */ + PluginStaticData staticData; + + /** + * The default configuration for this plugin, that is, default + * values for parameters etc. The contents of this structure are + * only valid if plugin is non-0. + */ + PluginConfiguration defaultConfiguration; +}; + +/** + * \class ConfigurationRequest + * + * A wrapper for a plugin pointer and PluginConfiguration, bundling up + * the data needed to configure a plugin after it has been loaded. + * + * \see PluginConfiguration, ConfigurationResponse, LoadRequest, LoadResponse + */ +struct ConfigurationRequest +{ +public: + ConfigurationRequest() : // invalid request by default + plugin(0) { } + + Vamp::Plugin *plugin; + PluginConfiguration configuration; +}; + +/** + * \class ConfigurationResponse + * + * The return value from a configuration request (i.e. setting the + * parameters and initialising the plugin). If the configuration was + * successful, the output list will contain the final + * post-initialisation output descriptors. If configuration failed, + * the output list will be empty. + * + * \see PluginConfiguration, ConfigurationRequest, LoadRequest, LoadResponse + */ +struct ConfigurationResponse +{ +public: + ConfigurationResponse() : // failed by default + plugin(0) { } + + Vamp::Plugin *plugin; + Vamp::Plugin::OutputList outputs; +}; + +/** + * \class ProcessRequest + * + * A structure that bundles the necessary data for making a process + * call: plugin, input buffers, and timestamp. Caller retains + * ownership of the plugin, but the buffers are passed "by value" to + * avoid ownership concerns. + * + * \see Vamp::Plugin::process() + */ +struct ProcessRequest +{ +public: + ProcessRequest() : // invalid by default + plugin(0) { } + + Vamp::Plugin *plugin; + std::vector<std::vector<float> > inputBuffers; + Vamp::RealTime timestamp; +}; + +/** + * \class ProcessResponse + * + * A structure that bundles the data returned by a process call. This + * is simply a FeatureSet wrapper that happens to reference the plugin + * as well. + * + * \see FinishResponse, Vamp::Plugin::process() + */ +struct ProcessResponse +{ +public: + ProcessResponse() : // invalid by default + plugin(0) { } + + Vamp::Plugin *plugin; + Vamp::Plugin::FeatureSet features; +}; + +/** + * \class FinishRequest + * + * A structure that bundles the necessary data for finishing + * processing, i.e. calling getRemainingFeatures(). This consists only + * of the plugin pointer. Caller retains ownership of the plugin. + * + * \see Vamp::Plugin::getRemainingFeatures() + */ +struct FinishRequest +{ +public: + FinishRequest() : // invalid by default + plugin(0) { } + + Vamp::Plugin *plugin; +}; + + +/** + * \class FinishResponse + * + * A structure that bundles the data returned by a + * getRemainingFeatures() call. This is identical to ProcessResponse. + * + * \see ProcessResponse, Vamp::Plugin::getRemainingFeatures() + */ +struct FinishResponse +{ +public: + FinishResponse() : // invalid by default + plugin(0) { } + + Vamp::Plugin *plugin; + Vamp::Plugin::FeatureSet features; +}; + +} + +#endif
--- a/vamp-support/RequestResponseType.h Thu Oct 13 17:00:06 2016 +0100 +++ b/vamp-support/RequestResponseType.h Thu Oct 13 18:05:35 2016 +0100 @@ -35,7 +35,7 @@ #ifndef PIPER_REQUEST_RESPONSE_TYPE_H #define PIPER_REQUEST_RESPONSE_TYPE_H -namespace piper { +namespace piper_vamp { enum class RRType { List, Load, Configure, Process, Finish, NotValid