Mercurial > hg > vampy-host
changeset 64:ee7542afa98e
Toward getting the results out in a nice form
author | Chris Cannam |
---|---|
date | Wed, 14 Jan 2015 11:33:01 +0000 |
parents | 34fc48e2df7e |
children | c5106210370e |
files | native/PyPluginObject.cpp test/test_process.py test/test_processBlock.py vamp/__init__.py |
diffstat | 4 files changed, 26 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/native/PyPluginObject.cpp Wed Jan 14 10:59:25 2015 +0000 +++ b/native/PyPluginObject.cpp Wed Jan 14 11:33:01 2015 +0000 @@ -175,7 +175,6 @@ { PyPluginObject *pd = getPluginObject(self); if (!pd) return 0; - Plugin::OutputList ol = pd->plugin->getOutputDescriptors(); PyObject *outputs = PyList_New(ol.size());
--- a/test/test_process.py Wed Jan 14 10:59:25 2015 +0000 +++ b/test/test_process.py Wed Jan 14 11:33:01 2015 +0000 @@ -7,7 +7,7 @@ rate = 44100 def test_process(): - buf = np.zeros(1024) - results = vamp.process(buf, rate, testPluginKey, {}, []) + buf = np.zeros(10240) + results = vamp.process(buf, rate, testPluginKey, {}, ["instants","curve-fsr"]) print("results = " + str(list(results))) return True
--- a/test/test_processBlock.py Wed Jan 14 10:59:25 2015 +0000 +++ b/test/test_processBlock.py Wed Jan 14 11:33:01 2015 +0000 @@ -4,8 +4,6 @@ testPluginKey = "vamp-test-plugin:vamp-test-plugin" -##!!! todo: support for, and test for, correct version of test plugin (with parameter) - rate = 44100 def test_load_unload():
--- a/vamp/__init__.py Wed Jan 14 10:59:25 2015 +0000 +++ b/vamp/__init__.py Wed Jan 14 11:33:01 2015 +0000 @@ -24,13 +24,20 @@ yield frame i = i + stepSize -def selectOutputs(result, outputs): - return result ##!!! for now +def process(data, samplerate, key, parameters, outputs): -def process(data, samplerate, key, parameters, outputs): plug = vampyhost.loadPlugin(key, samplerate, vampyhost.AdaptInputDomain + vampyhost.AdaptChannelCount) + + plugOuts = plug.getOutputs() + + outIndices = dict(zip([o["identifier"] for o in plugOuts], + range(0, len(plugOuts)))) # id -> n + + for o in outputs: + assert o in outIndices + stepSize = plug.getPreferredStepSize() blockSize = plug.getPreferredBlockSize() if blockSize == 0: @@ -40,11 +47,23 @@ channels = 1 if data.ndim > 1: channels = data.shape[0] + plug.initialise(channels, stepSize, blockSize) ff = framesFromArray(data, stepSize, blockSize) fi = 0 + for f in ff: - result = plug.processBlock(f, vampyhost.frame2RealTime(fi, samplerate)) - yield selectOutputs(result, outputs) + results = plug.processBlock(f, vampyhost.frame2RealTime(fi, samplerate)) + # results is a dict mapping output number -> list of feature dicts + if outputs == []: + if 0 in results: + for r in results[0]: + yield r + else: + for o in outputs: + if outIndices[o] in results: + for r in results[outIndices[o]]: + yield { o: r } fi = fi + stepSize + ##!!! now getRemainingFeatures