# HG changeset patch # User Chris Cannam # Date 1476115537 -3600 # Node ID 19e47ffed5252f576f35622c6749a7e8a3bdd4bf # Parent 02b69e2dc51f7882d431b3a66e0c5ae1db19bef3 Rearrange and rename VamPipe -> Piper as appropriate diff -r 02b69e2dc51f -r 19e47ffed525 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Mon Oct 10 17:05:37 2016 +0100 @@ -0,0 +1,2 @@ +syntax: glob +*.o diff -r 02b69e2dc51f -r 19e47ffed525 Makefile.inc.em --- a/Makefile.inc.em Fri Oct 07 16:43:18 2016 +0100 +++ b/Makefile.inc.em Mon Oct 10 17:05:37 2016 +0100 @@ -1,8 +1,9 @@ -ADAPTER_HEADERS := VamPipeAdapter.h VamPipePluginLibrary.h -ADAPTER_SOURCES := VamPipePluginLibrary.cpp +ADAPTER_HEADERS := PiperAdapter.h PiperPluginLibrary.h +ADAPTER_SOURCES := PiperPluginLibrary.cpp SDK_DIR := ../vamp-plugin-sdk +PIPERCPP_DIR := ../piper-cpp SDK_SOURCES := \ $(SDK_DIR)/src/vamp-hostsdk/PluginBufferingAdapter.cpp \ @@ -19,7 +20,7 @@ $(SDK_DIR)/src/vamp-sdk/FFT.cpp OTHER_SOURCES := \ - ../json/json11/json11.cpp + $(PIPERCPP_DIR)/json11/json11.cpp MODULE_EXT := .js MODULE := $(MODULE_NAME)$(MODULE_EXT) @@ -31,7 +32,7 @@ -s NO_FILESYSTEM=1 \ -s ERROR_ON_UNDEFINED_SYMBOLS=1 \ -s EXPORT_NAME="'$(MODULE_SYMBOL)'" \ - -s EXPORTED_FUNCTIONS="['_vampipeRequestJson','_vampipeProcessRaw','_vampipeFreeJson']" \ + -s EXPORTED_FUNCTIONS="['_piperRequestJson','_piperProcessRaw','_piperFreeJson']" \ $(EMFLAGS) CXX_SOURCES := $(MODULE_SOURCE) $(ADAPTER_SOURCES) $(PLUGIN_SOURCES) $(SDK_SOURCES) $(OTHER_SOURCES) @@ -45,7 +46,7 @@ DEFINES := $(DEFINES) -INCPATH := -I$(SDK_DIR) -I.. -I../json $(INCPATH) +INCPATH := -I$(SDK_DIR) -I$(PIPERCPP_DIR) $(INCPATH) CXXFLAGS := -std=c++11 -fPIC -Wall -Wextra $(DEFINES) $(OPTFLAGS) $(EMFLAGS) $(INCPATH) CFLAGS := -fPIC -Wall -Wextra $(DEFINES) $(OPTFLAGS) $(EMFLAGS) $(INCPATH) diff -r 02b69e2dc51f -r 19e47ffed525 Makefile.qm-vamp-plugins.em --- a/Makefile.qm-vamp-plugins.em Fri Oct 07 16:43:18 2016 +0100 +++ b/Makefile.qm-vamp-plugins.em Mon Oct 10 17:05:37 2016 +0100 @@ -1,7 +1,7 @@ MODULE_NAME := QMVampPlugins -QMV := ../../qm-vamp-plugins +QMV := ../qm-vamp-plugins DSP := $(QMV)/qm-dsp EXT := $(DSP)/ext diff -r 02b69e2dc51f -r 19e47ffed525 Makefile.silvet.em --- a/Makefile.silvet.em Fri Oct 07 16:43:18 2016 +0100 +++ b/Makefile.silvet.em Mon Oct 10 17:05:37 2016 +0100 @@ -1,7 +1,7 @@ MODULE_NAME := Silvet -SILVET_DIR := ../../silvet +SILVET_DIR := ../silvet SRC_DIR := $(SILVET_DIR)/src CQ_DIR := $(SILVET_DIR)/constant-q-cpp diff -r 02b69e2dc51f -r 19e47ffed525 Makefile.testplugin.em --- a/Makefile.testplugin.em Fri Oct 07 16:43:18 2016 +0100 +++ b/Makefile.testplugin.em Mon Oct 10 17:05:37 2016 +0100 @@ -1,7 +1,7 @@ MODULE_NAME := VampTestPlugin -TESTPLUGIN_DIR := ../../vamp-test-plugin +TESTPLUGIN_DIR := ../vamp-test-plugin INCPATH := -I$(TESTPLUGIN_DIR) diff -r 02b69e2dc51f -r 19e47ffed525 PiperAdapter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PiperAdapter.h Mon Oct 10 17:05:37 2016 +0100 @@ -0,0 +1,142 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Piper Vamp JSON Adapter + + Centre for Digital Music, Queen Mary, University of London. + Copyright 2015-2016 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_ADAPTER_H +#define PIPER_ADAPTER_H + +#include +#include +#include + +#include +#include +#include + +namespace piper { + +class PiperAdapterInterface +{ +public: + virtual Vamp::HostExt::PluginStaticData getStaticData() const = 0; + virtual Vamp::HostExt::LoadResponse loadPlugin(Vamp::HostExt::LoadRequest r) const = 0; + virtual Vamp::Plugin *createPlugin(float inputSampleRate) const = 0; +}; + +template +class PiperAdapterBase : public PiperAdapterInterface +{ + const int adaptInputDomain = 0x01; + const int adaptChannelCount = 0x02; + const int adaptBufferSize = 0x04; + +protected: + PiperAdapterBase(std::string libname) : m_soname(libname) { } + +public: + virtual Vamp::Plugin *createPlugin(float inputSampleRate) const = 0; + + virtual Vamp::HostExt::PluginStaticData getStaticData() const { + Vamp::Plugin *p = createPlugin(44100.f); + auto data = Vamp::HostExt::PluginStaticData::fromPlugin + (m_soname + ":" + p->getIdentifier(), + {}, //!!! todo: category - tricky one that + p); + delete p; + return data; + } + + virtual Vamp::HostExt::LoadResponse loadPlugin(Vamp::HostExt:: + LoadRequest r) const { + + // We assume the caller has guaranteed that the request is for + // the correct plugin (so we don't have to check the plugin + // key field here) + + Vamp::Plugin *p = createPlugin(r.inputSampleRate); + + if (r.adapterFlags & adaptInputDomain) { + if (p->getInputDomain() == Vamp::Plugin::FrequencyDomain) { + p = new Vamp::HostExt::PluginInputDomainAdapter(p); + } + } + + if (r.adapterFlags & adaptBufferSize) { + p = new Vamp::HostExt::PluginBufferingAdapter(p); + } + + if (r.adapterFlags & adaptChannelCount) { + p = new Vamp::HostExt::PluginChannelAdapter(p); + } + + Vamp::HostExt::LoadResponse response; + response.plugin = p; + + response.staticData = Vamp::HostExt::PluginStaticData::fromPlugin + (m_soname + ":" + p->getIdentifier(), + {}, //!!! todo: category - tricky one that + p); + + int defaultChannels = 0; + if (p->getMinChannelCount() == p->getMaxChannelCount()) { + defaultChannels = p->getMinChannelCount(); + } + + response.defaultConfiguration = Vamp::HostExt::PluginConfiguration::fromPlugin + (p, + defaultChannels, + p->getPreferredStepSize(), + p->getPreferredBlockSize()); + + return response; + } + +private: + std::string m_soname; +}; + +template +class PiperAdapter : public PiperAdapterBase

+{ +public: + PiperAdapter(std::string libname) : PiperAdapterBase

(libname) { } + + virtual Vamp::Plugin *createPlugin(float inputSampleRate) const { + return new P(inputSampleRate); + } +}; + +} + +#endif + diff -r 02b69e2dc51f -r 19e47ffed525 PiperPluginLibrary.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PiperPluginLibrary.cpp Mon Oct 10 17:05:37 2016 +0100 @@ -0,0 +1,322 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Piper Vamp JSON Adapter + + Centre for Digital Music, Queen Mary, University of London. + Copyright 2015-2016 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. +*/ + +#include "PiperPluginLibrary.h" +#include "PiperAdapter.h" + +#include "vamp-json/VampJson.h" + +using namespace std; +using namespace json11; + +namespace piper { + +//!!! too many explicit namespaces here + +//!!! dup with piper-convert +Json +convertRequestJson(string input, string &err) +{ + Json j = Json::parse(input, err); + if (err != "") { + err = "invalid json: " + err; + return {}; + } + if (!j.is_object()) { + err = "object expected at top level"; + } + return j; +} + +PiperPluginLibrary::PiperPluginLibrary(vector pp) : + m_useBase64(false) +{ + for (PiperAdapterInterface *p: pp) { + string key = p->getStaticData().pluginKey; + m_adapters[key] = p; + } +} + +Vamp::HostExt::ListResponse +PiperPluginLibrary::listPluginData() const +{ + Vamp::HostExt::ListResponse resp; + for (auto a: m_adapters) { + resp.available.push_back(a.second->getStaticData()); + } + return resp; +} + +Vamp::HostExt::LoadResponse +PiperPluginLibrary::loadPlugin(Vamp::HostExt::LoadRequest req, string &err) const +{ + string key = req.pluginKey; + if (m_adapters.find(key) != m_adapters.end()) { + auto resp = m_adapters.at(key)->loadPlugin(req); + if (!resp.plugin) { + // This should not actually happen -- the load call here + // is just an object construction, not a dynamic load. But + // report it if it does... + err = "failed to construct plugin with key " + key; + } + return resp; + } else { + err = "no adapter for plugin key " + key; + return {}; + } +} + +Vamp::HostExt::ConfigurationResponse +PiperPluginLibrary::configurePlugin(Vamp::HostExt::ConfigurationRequest req, + string &err) const +{ + for (Vamp::HostExt::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); + } + + Vamp::HostExt::ConfigurationResponse response; + + response.plugin = req.plugin; + + if (req.plugin->initialise(req.configuration.channelCount, + req.configuration.stepSize, + req.configuration.blockSize)) { + response.outputs = req.plugin->getOutputDescriptors(); + } else { + err = "configuration failed (wrong channel count, step size, block size?)"; + } + + return response; +} + +string +PiperPluginLibrary::processRawImpl(int handle, + const float *const *inputBuffers, + int sec, + int nsec) +{ + Vamp::Plugin *plugin = m_mapper.handleToPlugin(handle); + if (!plugin) { + return VampJson::fromError("unknown plugin handle", + RRType::Process, Json()) + .dump(); + } + + if (!m_mapper.isConfigured(handle)) { + return VampJson::fromError("plugin has not been configured", + RRType::Process, Json()) + .dump(); + } + + Vamp::RealTime timestamp(sec, nsec); + + Vamp::HostExt::ProcessResponse resp; + resp.plugin = plugin; + resp.features = plugin->process(inputBuffers, timestamp); + + m_useBase64 = true; + + return VampJson::fromRpcResponse_Process + (resp, m_mapper, + VampJson::BufferSerialisation::Base64, + Json()) + .dump(); +} + +string +PiperPluginLibrary::requestJsonImpl(string req) +{ + string err; + + Json j = convertRequestJson(req, err); + + // we don't care what this is, only that it is retained in the response: + auto id = j["id"]; + + Json rj; + if (err != "") { + return VampJson::fromError(err, RRType::NotValid, id).dump(); + } + + RRType type = VampJson::getRequestResponseType(j, err); + if (err != "") { + return VampJson::fromError(err, RRType::NotValid, id).dump(); + } + + VampJson::BufferSerialisation serialisation = + (m_useBase64 ? + VampJson::BufferSerialisation::Base64 : + VampJson::BufferSerialisation::Array); + + switch (type) { + + case RRType::List: + rj = VampJson::fromRpcResponse_List(listPluginData(), id); + break; + + case RRType::Load: + { + auto req = VampJson::toRpcRequest_Load(j, err); + if (err != "") { + rj = VampJson::fromError(err, type, id); + } else { + auto resp = loadPlugin(req, err); + if (err != "") { + rj = VampJson::fromError(err, type, id); + } else { + m_mapper.addPlugin(resp.plugin); + rj = VampJson::fromRpcResponse_Load(resp, m_mapper, id); + } + } + break; + } + + case RRType::Configure: + { + auto req = VampJson::toRpcRequest_Configure(j, m_mapper, err); + if (err != "") { + rj = VampJson::fromError(err, type, id); + } else { + auto h = m_mapper.pluginToHandle(req.plugin); + if (h == m_mapper.INVALID_HANDLE) { + rj = VampJson::fromError("unknown or invalid plugin handle", type, id); + } else if (m_mapper.isConfigured(h)) { + rj = VampJson::fromError("plugin has already been configured", type, id); + } else { + auto resp = configurePlugin(req, err); + if (err != "") { + rj = VampJson::fromError(err, type, id); + } else { + m_mapper.markConfigured(h, + req.configuration.channelCount, + req.configuration.blockSize); + rj = VampJson::fromRpcResponse_Configure(resp, m_mapper, id); + } + } + } + break; + } + + case RRType::Process: + { + VampJson::BufferSerialisation serialisation; + + auto req = VampJson::toRpcRequest_Process(j, m_mapper, + serialisation, err); + if (err != "") { + rj = VampJson::fromError(err, type, id); + } else { + auto h = m_mapper.pluginToHandle(req.plugin); + int channels = int(req.inputBuffers.size()); + if (h == m_mapper.INVALID_HANDLE) { + rj = VampJson::fromError("unknown or invalid plugin handle", type, id); + } else if (!m_mapper.isConfigured(h)) { + rj = VampJson::fromError("plugin has not been configured", type, id); + } else if (channels != m_mapper.getChannelCount(h)) { + rj = VampJson::fromError("wrong number of channels supplied", type, id); + } else { + + if (serialisation == VampJson::BufferSerialisation::Base64) { + m_useBase64 = true; + } + + size_t blockSize = m_mapper.getBlockSize(h); + + const float **fbuffers = new const float *[channels]; + for (int i = 0; i < channels; ++i) { + if (req.inputBuffers[i].size() != blockSize) { + delete[] fbuffers; + fbuffers = 0; + rj = VampJson::fromError("wrong block size supplied", type, id); + break; + } + fbuffers[i] = req.inputBuffers[i].data(); + } + + if (fbuffers) { + Vamp::HostExt::ProcessResponse resp; + resp.plugin = req.plugin; + resp.features = req.plugin->process(fbuffers, req.timestamp); + delete[] fbuffers; + rj = VampJson::fromRpcResponse_Process + (resp, m_mapper, serialisation, id); + } + } + } + break; + } + + case RRType::Finish: + { + auto req = VampJson::toRpcRequest_Finish(j, m_mapper, err); + if (err != "") { + rj = VampJson::fromError(err, type, id); + } else { + auto h = m_mapper.pluginToHandle(req.plugin); + if (h == m_mapper.INVALID_HANDLE) { + rj = VampJson::fromError("unknown or invalid plugin handle", type, id); + } else if (!m_mapper.isConfigured(h)) { + rj = VampJson::fromError("plugin has not been configured", type, id); + } else { + + Vamp::HostExt::ProcessResponse resp; + resp.plugin = req.plugin; + resp.features = req.plugin->getRemainingFeatures(); + + rj = VampJson::fromRpcResponse_Finish + (resp, m_mapper, serialisation, id); + + m_mapper.removePlugin(h); + delete req.plugin; + } + } + break; + } + + case RRType::NotValid: + rj = VampJson::fromError("invalid request", type, id); + break; + } + + return rj.dump(); +} + +} + diff -r 02b69e2dc51f -r 19e47ffed525 PiperPluginLibrary.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PiperPluginLibrary.h Mon Oct 10 17:05:37 2016 +0100 @@ -0,0 +1,89 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Piper Vamp JSON Adapter + + Centre for Digital Music, Queen Mary, University of London. + Copyright 2015-2016 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_LIBRARY_H +#define PIPER_PLUGIN_LIBRARY_H + +#include "vamp-support/CountingPluginHandleMapper.h" + +#include +#include + +#include +#include +#include + +namespace piper { + +class PiperAdapterInterface; + +class PiperPluginLibrary +{ +public: + PiperPluginLibrary(std::vector pp); + + const char *requestJson(const char *request) { + return strdup(requestJsonImpl(request).c_str()); + } + + const char *processRaw(int handle, const float *const *inputBuffers, + int sec, int nsec) { + return strdup(processRawImpl(handle, inputBuffers, sec, nsec).c_str()); + } + + void freeJson(const char *json) { + free(const_cast(json)); + } + +private: + std::string requestJsonImpl(std::string req); + std::string processRawImpl(int, const float *const *, int, int); + + Vamp::HostExt::ListResponse listPluginData() const; + Vamp::HostExt::LoadResponse loadPlugin(Vamp::HostExt::LoadRequest r, + std::string &err) const; + Vamp::HostExt::ConfigurationResponse configurePlugin(Vamp::HostExt:: + ConfigurationRequest r, + std::string &err) + const; + + // map from pluginKey -> adapter + std::map m_adapters; + CountingPluginHandleMapper m_mapper; + bool m_useBase64; +}; + +} + +#endif diff -r 02b69e2dc51f -r 19e47ffed525 VamPipeAdapter.h --- a/VamPipeAdapter.h Fri Oct 07 16:43:18 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,142 +0,0 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -/* - VamPipe - - Centre for Digital Music, Queen Mary, University of London. - Copyright 2015-2016 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 VAMPIPE_ADAPTER_H -#define VAMPIPE_ADAPTER_H - -#include -#include -#include - -#include -#include -#include - -namespace vampipe { - -class VamPipeAdapterInterface -{ -public: - virtual Vamp::HostExt::PluginStaticData getStaticData() const = 0; - virtual Vamp::HostExt::LoadResponse loadPlugin(Vamp::HostExt::LoadRequest r) const = 0; - virtual Vamp::Plugin *createPlugin(float inputSampleRate) const = 0; -}; - -template -class VamPipeAdapterBase : public VamPipeAdapterInterface -{ - const int adaptInputDomain = 0x01; - const int adaptChannelCount = 0x02; - const int adaptBufferSize = 0x04; - -protected: - VamPipeAdapterBase(std::string libname) : m_soname(libname) { } - -public: - virtual Vamp::Plugin *createPlugin(float inputSampleRate) const = 0; - - virtual Vamp::HostExt::PluginStaticData getStaticData() const { - Vamp::Plugin *p = createPlugin(44100.f); - auto data = Vamp::HostExt::PluginStaticData::fromPlugin - (m_soname + ":" + p->getIdentifier(), - {}, //!!! todo: category - tricky one that - p); - delete p; - return data; - } - - virtual Vamp::HostExt::LoadResponse loadPlugin(Vamp::HostExt:: - LoadRequest r) const { - - // We assume the caller has guaranteed that the request is for - // the correct plugin (so we don't have to check the plugin - // key field here) - - Vamp::Plugin *p = createPlugin(r.inputSampleRate); - - if (r.adapterFlags & adaptInputDomain) { - if (p->getInputDomain() == Vamp::Plugin::FrequencyDomain) { - p = new Vamp::HostExt::PluginInputDomainAdapter(p); - } - } - - if (r.adapterFlags & adaptBufferSize) { - p = new Vamp::HostExt::PluginBufferingAdapter(p); - } - - if (r.adapterFlags & adaptChannelCount) { - p = new Vamp::HostExt::PluginChannelAdapter(p); - } - - Vamp::HostExt::LoadResponse response; - response.plugin = p; - - response.staticData = Vamp::HostExt::PluginStaticData::fromPlugin - (m_soname + ":" + p->getIdentifier(), - {}, //!!! todo: category - tricky one that - p); - - int defaultChannels = 0; - if (p->getMinChannelCount() == p->getMaxChannelCount()) { - defaultChannels = p->getMinChannelCount(); - } - - response.defaultConfiguration = Vamp::HostExt::PluginConfiguration::fromPlugin - (p, - defaultChannels, - p->getPreferredStepSize(), - p->getPreferredBlockSize()); - - return response; - } - -private: - std::string m_soname; -}; - -template -class VamPipeAdapter : public VamPipeAdapterBase

-{ -public: - VamPipeAdapter(std::string libname) : VamPipeAdapterBase

(libname) { } - - virtual Vamp::Plugin *createPlugin(float inputSampleRate) const { - return new P(inputSampleRate); - } -}; - -} - -#endif - diff -r 02b69e2dc51f -r 19e47ffed525 VamPipePluginLibrary.cpp --- a/VamPipePluginLibrary.cpp Fri Oct 07 16:43:18 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,321 +0,0 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -/* - VamPipe - - Centre for Digital Music, Queen Mary, University of London. - Copyright 2015-2016 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. -*/ - -#include "VamPipePluginLibrary.h" -#include "VamPipeAdapter.h" -#include "json/VampJson.h" - -using namespace std; -using namespace json11; - -namespace vampipe { - -//!!! too many explicit namespaces here - -//!!! dup with vampipe-convert -Json -convertRequestJson(string input, string &err) -{ - Json j = Json::parse(input, err); - if (err != "") { - err = "invalid json: " + err; - return {}; - } - if (!j.is_object()) { - err = "object expected at top level"; - } - return j; -} - -VamPipePluginLibrary::VamPipePluginLibrary(vector pp) : - m_useBase64(false) -{ - for (VamPipeAdapterInterface *p: pp) { - string key = p->getStaticData().pluginKey; - m_adapters[key] = p; - } -} - -Vamp::HostExt::ListResponse -VamPipePluginLibrary::listPluginData() const -{ - Vamp::HostExt::ListResponse resp; - for (auto a: m_adapters) { - resp.plugins.push_back(a.second->getStaticData()); - } - return resp; -} - -Vamp::HostExt::LoadResponse -VamPipePluginLibrary::loadPlugin(Vamp::HostExt::LoadRequest req, string &err) const -{ - string key = req.pluginKey; - if (m_adapters.find(key) != m_adapters.end()) { - auto resp = m_adapters.at(key)->loadPlugin(req); - if (!resp.plugin) { - // This should not actually happen -- the load call here - // is just an object construction, not a dynamic load. But - // report it if it does... - err = "failed to construct plugin with key " + key; - } - return resp; - } else { - err = "no adapter for plugin key " + key; - return {}; - } -} - -Vamp::HostExt::ConfigurationResponse -VamPipePluginLibrary::configurePlugin(Vamp::HostExt::ConfigurationRequest req, - string &err) const -{ - for (Vamp::HostExt::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); - } - - Vamp::HostExt::ConfigurationResponse response; - - response.plugin = req.plugin; - - if (req.plugin->initialise(req.configuration.channelCount, - req.configuration.stepSize, - req.configuration.blockSize)) { - response.outputs = req.plugin->getOutputDescriptors(); - } else { - err = "configuration failed (wrong channel count, step size, block size?)"; - } - - return response; -} - -string -VamPipePluginLibrary::processRawImpl(int handle, - const float *const *inputBuffers, - int sec, - int nsec) -{ - Vamp::Plugin *plugin = m_mapper.handleToPlugin(handle); - if (!plugin) { - return VampJson::fromError("unknown plugin handle", - RRType::Process, Json()) - .dump(); - } - - if (!m_mapper.isConfigured(handle)) { - return VampJson::fromError("plugin has not been configured", - RRType::Process, Json()) - .dump(); - } - - Vamp::RealTime timestamp(sec, nsec); - - Vamp::HostExt::ProcessResponse resp; - resp.plugin = plugin; - resp.features = plugin->process(inputBuffers, timestamp); - - m_useBase64 = true; - - return VampJson::fromRpcResponse_Process - (resp, m_mapper, - VampJson::BufferSerialisation::Base64, - Json()) - .dump(); -} - -string -VamPipePluginLibrary::requestJsonImpl(string req) -{ - string err; - - Json j = convertRequestJson(req, err); - - // we don't care what this is, only that it is retained in the response: - auto id = j["id"]; - - Json rj; - if (err != "") { - return VampJson::fromError(err, RRType::NotValid, id).dump(); - } - - RRType type = VampJson::getRequestResponseType(j, err); - if (err != "") { - return VampJson::fromError(err, RRType::NotValid, id).dump(); - } - - VampJson::BufferSerialisation serialisation = - (m_useBase64 ? - VampJson::BufferSerialisation::Base64 : - VampJson::BufferSerialisation::Array); - - switch (type) { - - case RRType::List: - rj = VampJson::fromRpcResponse_List(listPluginData(), id); - break; - - case RRType::Load: - { - auto req = VampJson::toRpcRequest_Load(j, err); - if (err != "") { - rj = VampJson::fromError(err, type, id); - } else { - auto resp = loadPlugin(req, err); - if (err != "") { - rj = VampJson::fromError(err, type, id); - } else { - m_mapper.addPlugin(resp.plugin); - rj = VampJson::fromRpcResponse_Load(resp, m_mapper, id); - } - } - break; - } - - case RRType::Configure: - { - auto req = VampJson::toRpcRequest_Configure(j, m_mapper, err); - if (err != "") { - rj = VampJson::fromError(err, type, id); - } else { - auto h = m_mapper.pluginToHandle(req.plugin); - if (h == m_mapper.INVALID_HANDLE) { - rj = VampJson::fromError("unknown or invalid plugin handle", type, id); - } else if (m_mapper.isConfigured(h)) { - rj = VampJson::fromError("plugin has already been configured", type, id); - } else { - auto resp = configurePlugin(req, err); - if (err != "") { - rj = VampJson::fromError(err, type, id); - } else { - m_mapper.markConfigured(h, - req.configuration.channelCount, - req.configuration.blockSize); - rj = VampJson::fromRpcResponse_Configure(resp, m_mapper, id); - } - } - } - break; - } - - case RRType::Process: - { - VampJson::BufferSerialisation serialisation; - - auto req = VampJson::toRpcRequest_Process(j, m_mapper, - serialisation, err); - if (err != "") { - rj = VampJson::fromError(err, type, id); - } else { - auto h = m_mapper.pluginToHandle(req.plugin); - int channels = int(req.inputBuffers.size()); - if (h == m_mapper.INVALID_HANDLE) { - rj = VampJson::fromError("unknown or invalid plugin handle", type, id); - } else if (!m_mapper.isConfigured(h)) { - rj = VampJson::fromError("plugin has not been configured", type, id); - } else if (channels != m_mapper.getChannelCount(h)) { - rj = VampJson::fromError("wrong number of channels supplied", type, id); - } else { - - if (serialisation == VampJson::BufferSerialisation::Base64) { - m_useBase64 = true; - } - - size_t blockSize = m_mapper.getBlockSize(h); - - const float **fbuffers = new const float *[channels]; - for (int i = 0; i < channels; ++i) { - if (req.inputBuffers[i].size() != blockSize) { - delete[] fbuffers; - fbuffers = 0; - rj = VampJson::fromError("wrong block size supplied", type, id); - break; - } - fbuffers[i] = req.inputBuffers[i].data(); - } - - if (fbuffers) { - Vamp::HostExt::ProcessResponse resp; - resp.plugin = req.plugin; - resp.features = req.plugin->process(fbuffers, req.timestamp); - delete[] fbuffers; - rj = VampJson::fromRpcResponse_Process - (resp, m_mapper, serialisation, id); - } - } - } - break; - } - - case RRType::Finish: - { - auto req = VampJson::toRpcRequest_Finish(j, m_mapper, err); - if (err != "") { - rj = VampJson::fromError(err, type, id); - } else { - auto h = m_mapper.pluginToHandle(req.plugin); - if (h == m_mapper.INVALID_HANDLE) { - rj = VampJson::fromError("unknown or invalid plugin handle", type, id); - } else if (!m_mapper.isConfigured(h)) { - rj = VampJson::fromError("plugin has not been configured", type, id); - } else { - - Vamp::HostExt::ProcessResponse resp; - resp.plugin = req.plugin; - resp.features = req.plugin->getRemainingFeatures(); - - rj = VampJson::fromRpcResponse_Finish - (resp, m_mapper, serialisation, id); - - m_mapper.removePlugin(h); - delete req.plugin; - } - } - break; - } - - case RRType::NotValid: - rj = VampJson::fromError("invalid request", type, id); - break; - } - - return rj.dump(); -} - -} - diff -r 02b69e2dc51f -r 19e47ffed525 VamPipePluginLibrary.h --- a/VamPipePluginLibrary.h Fri Oct 07 16:43:18 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -/* - VamPipe - - Centre for Digital Music, Queen Mary, University of London. - Copyright 2015-2016 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 VAMPIPE_PLUGIN_LIBRARY_H -#define VAMPIPE_PLUGIN_LIBRARY_H - -#include "bits/CountingPluginHandleMapper.h" - -#include -#include - -#include -#include -#include - -namespace vampipe { - -class VamPipeAdapterInterface; - -class VamPipePluginLibrary -{ -public: - VamPipePluginLibrary(std::vector pp); - - const char *requestJson(const char *request) { - return strdup(requestJsonImpl(request).c_str()); - } - - const char *processRaw(int handle, const float *const *inputBuffers, - int sec, int nsec) { - return strdup(processRawImpl(handle, inputBuffers, sec, nsec).c_str()); - } - - void freeJson(const char *json) { - free(const_cast(json)); - } - -private: - std::string requestJsonImpl(std::string req); - std::string processRawImpl(int, const float *const *, int, int); - - Vamp::HostExt::ListResponse listPluginData() const; - Vamp::HostExt::LoadResponse loadPlugin(Vamp::HostExt::LoadRequest r, - std::string &err) const; - Vamp::HostExt::ConfigurationResponse configurePlugin(Vamp::HostExt:: - ConfigurationRequest r, - std::string &err) - const; - - // map from pluginKey -> adapter - std::map m_adapters; - CountingPluginHandleMapper m_mapper; - bool m_useBase64; -}; - -} - -#endif diff -r 02b69e2dc51f -r 19e47ffed525 example.cpp --- a/example.cpp Fri Oct 07 16:43:18 2016 +0100 +++ b/example.cpp Mon Oct 10 17:05:37 2016 +0100 @@ -1,7 +1,7 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ /* - VamPipe + Piper Centre for Digital Music, Queen Mary, University of London. Copyright 2015-2016 QMUL. @@ -32,29 +32,29 @@ authorization. */ -#include "VamPipeAdapter.h" -#include "VamPipePluginLibrary.h" +#include "PiperAdapter.h" +#include "PiperPluginLibrary.h" -#include "vamp-plugin-sdk/examples/ZeroCrossing.h" -#include "vamp-plugin-sdk/examples/SpectralCentroid.h" -#include "vamp-plugin-sdk/examples/PercussionOnsetDetector.h" -#include "vamp-plugin-sdk/examples/FixedTempoEstimator.h" -#include "vamp-plugin-sdk/examples/AmplitudeFollower.h" -#include "vamp-plugin-sdk/examples/PowerSpectrum.h" +#include "examples/ZeroCrossing.h" +#include "examples/SpectralCentroid.h" +#include "examples/PercussionOnsetDetector.h" +#include "examples/FixedTempoEstimator.h" +#include "examples/AmplitudeFollower.h" +#include "examples/PowerSpectrum.h" -using vampipe::VamPipeAdapter; -using vampipe::VamPipePluginLibrary; +using piper::PiperAdapter; +using piper::PiperPluginLibrary; static std::string soname("vamp-example-plugins"); -static VamPipeAdapter zeroCrossingAdapter(soname); -static VamPipeAdapter spectralCentroidAdapter(soname); -static VamPipeAdapter percussionOnsetAdapter(soname); -static VamPipeAdapter fixedTempoAdapter(soname); -static VamPipeAdapter amplitudeAdapter(soname); -static VamPipeAdapter powerSpectrumAdapter(soname); +static PiperAdapter zeroCrossingAdapter(soname); +static PiperAdapter spectralCentroidAdapter(soname); +static PiperAdapter percussionOnsetAdapter(soname); +static PiperAdapter fixedTempoAdapter(soname); +static PiperAdapter amplitudeAdapter(soname); +static PiperAdapter powerSpectrumAdapter(soname); -static VamPipePluginLibrary library({ +static PiperPluginLibrary library({ &zeroCrossingAdapter, &spectralCentroidAdapter, &percussionOnsetAdapter, @@ -65,18 +65,18 @@ extern "C" { -const char *vampipeRequestJson(const char *request) { +const char *piperRequestJson(const char *request) { return library.requestJson(request); } -const char *vampipeProcessRaw(int handle, +const char *piperProcessRaw(int handle, const float *const *inputBuffers, int sec, int nsec) { return library.processRaw(handle, inputBuffers, sec, nsec); } -void vampipeFreeJson(const char *json) { +void piperFreeJson(const char *json) { return library.freeJson(json); } diff -r 02b69e2dc51f -r 19e47ffed525 perf-test-node.js --- a/perf-test-node.js Fri Oct 07 16:43:18 2016 +0100 +++ b/perf-test-node.js Mon Oct 10 17:05:37 2016 +0100 @@ -8,24 +8,24 @@ // "string", in which case Emscripten will take care of // conversions. But it's not clear how one would manage memory for // newly-constructed returned C strings -- the returned pointer from -// vampipeRequestJson would appear (?) to be thrown away by the +// piperRequestJson would appear (?) to be thrown away by the // Emscripten string converter if we declare it as returning a string, -// so we have no opportunity to pass it to vampipeFreeJson, which +// so we have no opportunity to pass it to piperFreeJson, which // suggests this would leak memory if the string isn't static. Not // wholly sure though. Anyway, passing and returning pointers (as // numbers) means we can manage the Emscripten heap memory however we // want in our request wrapper function below. -var vampipeRequestJson = exampleModule.cwrap( - 'vampipeRequestJson', 'number', ['number'] +var piperRequestJson = exampleModule.cwrap( + 'piperRequestJson', 'number', ['number'] ); -var vampipeProcessRaw = exampleModule.cwrap( - "vampipeProcessRaw", "number", ["number", "number", "number", "number"] +var piperProcessRaw = exampleModule.cwrap( + "piperProcessRaw", "number", ["number", "number", "number", "number"] ); -var vampipeFreeJson = exampleModule.cwrap( - 'vampipeFreeJson', 'void', ['number'] +var piperFreeJson = exampleModule.cwrap( + 'piperFreeJson', 'void', ['number'] ); function note(blah) { @@ -53,7 +53,7 @@ buffers[i] = framesPtr; } - const responseJson = vampipeProcessRaw( + const responseJson = piperProcessRaw( request.handle, buffersPtr, request.processInput.timestamp.s, @@ -67,7 +67,7 @@ const responseJstr = exampleModule.Pointer_stringify(responseJson); const response = JSON.parse(responseJstr); - vampipeFreeJson(responseJson); + piperFreeJson(responseJson); return response; } @@ -96,10 +96,10 @@ // don't mention this). Note the *Cstr values are Emscripten heap // pointers var inCstr = m.allocate(m.intArrayFromString(jsonStr), 'i8', m.ALLOC_NORMAL); - var outCstr = vampipeRequestJson(inCstr); + var outCstr = piperRequestJson(inCstr); m._free(inCstr); var result = m.Pointer_stringify(outCstr); - vampipeFreeJson(outCstr); + piperFreeJson(outCstr); note("Returned JSON = " + result); return result; } diff -r 02b69e2dc51f -r 19e47ffed525 perf-test.js --- a/perf-test.js Fri Oct 07 16:43:18 2016 +0100 +++ b/perf-test.js Mon Oct 10 17:05:37 2016 +0100 @@ -6,24 +6,24 @@ // "string", in which case Emscripten will take care of // conversions. But it's not clear how one would manage memory for // newly-constructed returned C strings -- the returned pointer from -// vampipeRequestJson would appear (?) to be thrown away by the +// piperRequestJson would appear (?) to be thrown away by the // Emscripten string converter if we declare it as returning a string, -// so we have no opportunity to pass it to vampipeFreeJson, which +// so we have no opportunity to pass it to piperFreeJson, which // suggests this would leak memory if the string isn't static. Not // wholly sure though. Anyway, passing and returning pointers (as // numbers) means we can manage the Emscripten heap memory however we // want in our request wrapper function below. -var vampipeRequestJson = exampleModule.cwrap( - 'vampipeRequestJson', 'number', ['number'] +var piperRequestJson = exampleModule.cwrap( + 'piperRequestJson', 'number', ['number'] ); -var vampipeProcessRaw = exampleModule.cwrap( - "vampipeProcessRaw", "number", ["number", "number", "number", "number"] +var piperProcessRaw = exampleModule.cwrap( + "piperProcessRaw", "number", ["number", "number", "number", "number"] ); -var vampipeFreeJson = exampleModule.cwrap( - 'vampipeFreeJson', 'void', ['number'] +var piperFreeJson = exampleModule.cwrap( + 'piperFreeJson', 'void', ['number'] ); function note(blah) { @@ -51,7 +51,7 @@ buffers[i] = framesPtr; } - const responseJson = vampipeProcessRaw( + const responseJson = piperProcessRaw( request.handle, buffersPtr, request.processInput.timestamp.s, @@ -65,7 +65,7 @@ const responseJstr = exampleModule.Pointer_stringify(responseJson); const response = JSON.parse(responseJstr); - vampipeFreeJson(responseJson); + piperFreeJson(responseJson); return response; } @@ -94,10 +94,10 @@ // don't mention this). Note the *Cstr values are Emscripten heap // pointers var inCstr = m.allocate(m.intArrayFromString(jsonStr), 'i8', m.ALLOC_NORMAL); - var outCstr = vampipeRequestJson(inCstr); + var outCstr = piperRequestJson(inCstr); m._free(inCstr); var result = m.Pointer_stringify(outCstr); - vampipeFreeJson(outCstr); + piperFreeJson(outCstr); note("Returned JSON = " + result); return result; } diff -r 02b69e2dc51f -r 19e47ffed525 qm-vamp-plugins.cpp --- a/qm-vamp-plugins.cpp Fri Oct 07 16:43:18 2016 +0100 +++ b/qm-vamp-plugins.cpp Mon Oct 10 17:05:37 2016 +0100 @@ -1,7 +1,7 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ /* - VamPipe + Piper Centre for Digital Music, Queen Mary, University of London. Copyright 2015-2016 QMUL. @@ -32,8 +32,8 @@ authorization. */ -#include "VamPipeAdapter.h" -#include "VamPipePluginLibrary.h" +#include "PiperAdapter.h" +#include "PiperPluginLibrary.h" #include "plugins/BeatTrack.h" #include "plugins/OnsetDetect.h" @@ -49,26 +49,26 @@ #include "plugins/DWT.h" #include "plugins/Transcription.h" -using vampipe::VamPipeAdapter; -using vampipe::VamPipePluginLibrary; +using piper::PiperAdapter; +using piper::PiperPluginLibrary; static std::string soname("qm-vamp-plugins"); -static VamPipeAdapter beatTrackerAdapter(soname); -static VamPipeAdapter onsetDetectorAdapter(soname); -static VamPipeAdapter chromagramPluginAdapter(soname); -static VamPipeAdapter constantQAdapter(soname); -static VamPipeAdapter tonalChangeDetectorAdapter(soname); -static VamPipeAdapter keyDetectorAdapter(soname); -static VamPipeAdapter mfccPluginAdapter(soname); -static VamPipeAdapter segmenterPluginAdapter(soname); -static VamPipeAdapter similarityPluginAdapter(soname); -static VamPipeAdapter barBeatTrackPluginAdapter(soname); -//!!!static VamPipeAdapter adaptiveSpectrogramAdapter(soname); -static VamPipeAdapter dwtAdapter(soname); -static VamPipeAdapter transcriptionAdapter(soname); +static PiperAdapter beatTrackerAdapter(soname); +static PiperAdapter onsetDetectorAdapter(soname); +static PiperAdapter chromagramPluginAdapter(soname); +static PiperAdapter constantQAdapter(soname); +static PiperAdapter tonalChangeDetectorAdapter(soname); +static PiperAdapter keyDetectorAdapter(soname); +static PiperAdapter mfccPluginAdapter(soname); +static PiperAdapter segmenterPluginAdapter(soname); +static PiperAdapter similarityPluginAdapter(soname); +static PiperAdapter barBeatTrackPluginAdapter(soname); +//!!!static PiperAdapter adaptiveSpectrogramAdapter(soname); +static PiperAdapter dwtAdapter(soname); +static PiperAdapter transcriptionAdapter(soname); -static VamPipePluginLibrary library({ +static PiperPluginLibrary library({ &beatTrackerAdapter, &onsetDetectorAdapter, &chromagramPluginAdapter, @@ -86,18 +86,18 @@ extern "C" { -const char *vampipeRequestJson(const char *request) { +const char *piperRequestJson(const char *request) { return library.requestJson(request); } -const char *vampipeProcessRaw(int handle, +const char *piperProcessRaw(int handle, const float *const *inputBuffers, int sec, int nsec) { return library.processRaw(handle, inputBuffers, sec, nsec); } -void vampipeFreeJson(const char *json) { +void piperFreeJson(const char *json) { return library.freeJson(json); } diff -r 02b69e2dc51f -r 19e47ffed525 quick-test.html --- a/quick-test.html Fri Oct 07 16:43:18 2016 +0100 +++ b/quick-test.html Mon Oct 10 17:05:37 2016 +0100 @@ -1,7 +1,7 @@ - VamPipe Adapter Test + Piper Adapter Test