# HG changeset patch # User Chris Cannam # Date 1421235181 0 # Node ID ee7542afa98e021bd6a4fdb0cdee21aa7003face # Parent 34fc48e2df7e2e1a12f3161e8b5694f317c38c79 Toward getting the results out in a nice form diff -r 34fc48e2df7e -r ee7542afa98e native/PyPluginObject.cpp --- 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()); diff -r 34fc48e2df7e -r ee7542afa98e test/test_process.py --- 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 diff -r 34fc48e2df7e -r ee7542afa98e test/test_processBlock.py --- 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(): diff -r 34fc48e2df7e -r ee7542afa98e vamp/__init__.py --- 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