# HG changeset patch # User Chris Cannam # Date 1421231815 0 # Node ID f7ee26ca530441e72cb364d6650055059bae3c0e # Parent 2437c52b4d62a0bca6bb96d3873a6982da39218f Start on the main process stuff diff -r 2437c52b4d62 -r f7ee26ca5304 test/test_process.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/test_process.py Wed Jan 14 10:36:55 2015 +0000 @@ -0,0 +1,13 @@ + +import vamp +import numpy as np + +testPluginKey = "vamp-test-plugin:vamp-test-plugin" + +rate = 44100 + +def test_process(): + buf = np.zeros(1024) + results = vamp.process(buf, rate, testPluginKey, {}, []) + print("results = " + str(list(results))) + return True diff -r 2437c52b4d62 -r f7ee26ca5304 vamp/__init__.py --- a/vamp/__init__.py Wed Jan 14 10:36:22 2015 +0000 +++ b/vamp/__init__.py Wed Jan 14 10:36:55 2015 +0000 @@ -24,11 +24,27 @@ yield frame i = i + stepSize +def selectOutputs(result, outputs): + return result ##!!! for now + def process(data, samplerate, key, parameters, outputs): plug = vampyhost.loadPlugin(key, samplerate, vampyhost.AdaptInputDomain + vampyhost.AdaptChannelCount) stepSize = plug.getPreferredStepSize() blockSize = plug.getPreferredBlockSize() + if blockSize == 0: + blockSize = 1024 + if stepSize == 0: + stepSize = blockSize ##!!! or blockSize/2, but check this with input domain adapter + channels = 1 + if data.ndim > 1: + channels = data.shape[0] + plug.initialise(channels, stepSize, blockSize) ff = framesFromArray(data, stepSize, blockSize) - return True + fi = 0 + for f in ff: + result = plug.processBlock(f, vampyhost.frame2RealTime(fi, samplerate)) + yield selectOutputs(result, outputs) + fi = fi + stepSize +