Mercurial > hg > piper-vamp-js
changeset 138:4b593b643918
Update API usage throughout to match revised framing layout
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Wed, 08 Feb 2017 18:01:59 +0000 |
parents | 648a40f5e322 |
children | c9a8c7ef9c12 |
files | Makefile.inc src/PiperPluginLibrary.cpp test/node-load-test.js |
diffstat | 3 files changed, 50 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile.inc Thu Jan 19 09:27:59 2017 +0000 +++ b/Makefile.inc Wed Feb 08 18:01:59 2017 +0000 @@ -46,7 +46,7 @@ $(SDK_DIR)/src/vamp-sdk/FFT.cpp OTHER_SOURCES := \ - $(PIPERCPP_DIR)/json11/json11.cpp + $(PIPERCPP_DIR)/ext/json11/json11.cpp EM_MODULE_EXT := .js EM_MODULE := $(MODULE_NAME)$(EM_MODULE_EXT) @@ -71,7 +71,7 @@ OPTFLAGS ?= -O DEFINES := $(DEFINES) -INCLUDES := -I$(SRC_DIR) -I$(SDK_DIR) -I$(PIPERCPP_DIR) $(INCLUDES) +INCLUDES := -I$(SRC_DIR) -I$(SDK_DIR) -I$(PIPERCPP_DIR) -I$(PIPERCPP_DIR)/ext $(INCLUDES) em: $(EM_MODULE) em: CXX := em++
--- a/src/PiperPluginLibrary.cpp Thu Jan 19 09:27:59 2017 +0000 +++ b/src/PiperPluginLibrary.cpp Wed Feb 08 18:01:59 2017 +0000 @@ -114,7 +114,7 @@ ConfigurationResponse PiperPluginLibrary::configurePlugin(ConfigurationRequest req, - string &err) const + string &err) const { for (PluginConfiguration::ParameterMap::const_iterator i = req.configuration.parameterValues.begin(); @@ -130,12 +130,46 @@ response.plugin = req.plugin; + Framing pluginPreferredFraming; + pluginPreferredFraming.stepSize = req.plugin->getPreferredStepSize(); + pluginPreferredFraming.blockSize = req.plugin->getPreferredBlockSize(); + + if (req.plugin->initialise(req.configuration.channelCount, - req.configuration.stepSize, - req.configuration.blockSize)) { + req.configuration.framing.stepSize, + req.configuration.framing.blockSize)) { + response.outputs = req.plugin->getOutputDescriptors(); + + // If the Vamp plugin initialise() call succeeds, then by + // definition it is accepting the step and block size we + // passed to it + response.framing = req.configuration.framing; + } else { - err = "configuration failed (wrong channel count, step size, block size?)"; + + // If initialise() fails, one reason could be that it didn't + // like the passed-in framing (step and block size). We need + // to check whether the passed-in framing differs from the + // plugin's preferences; if so, then we form a working + // supposition that initialise() failed because of this. Vamp + // contains nothing to allow us to test this, except to try + // initialise() again with different values. So we try again + // with the values the plugin told us it would prefer and, if + // that succeeds, return them in a successful response. + // + // See also LoaderRequests in piper-cpp/vamp-support. + // + if (req.plugin->initialise(req.configuration.channelCount, + pluginPreferredFraming.stepSize, + pluginPreferredFraming.blockSize)) { + + response.outputs = req.plugin->getOutputDescriptors(); + response.framing = pluginPreferredFraming; + + } else { + err = "configuration failed (wrong channel count, step size, block size?)"; + } } return response; @@ -248,7 +282,7 @@ } else { m_mapper.markConfigured(h, req.configuration.channelCount, - req.configuration.blockSize); + req.configuration.framing.blockSize); rj = VampJson::fromRpcResponse_Configure(resp, m_mapper, id); } }
--- a/test/node-load-test.js Thu Jan 19 09:27:59 2017 +0000 +++ b/test/node-load-test.js Wed Feb 08 18:01:59 2017 +0000 @@ -183,22 +183,27 @@ }); checkSuccess(response); - const blockSize = response.result.defaultConfiguration.blockSize; - const stepSize = response.result.defaultConfiguration.stepSize; + var blockSize = response.result.defaultConfiguration.framing.blockSize; + var stepSize = response.result.defaultConfiguration.framing.stepSize; response = request({ method: "configure", params: { handle: 1, configuration: { - blockSize: blockSize, - stepSize: stepSize, + framing: { + blockSize: blockSize, + stepSize: stepSize, + }, channelCount: 1 } } }); checkSuccess(response); + blockSize = response.result.framing.blockSize; + stepSize = response.result.framing.stepSize; + const nblocks = 1000; const makeBlock = (n => {