Mercurial > hg > vampy-host
changeset 61:f7ee26ca5304
Start on the main process stuff
author | Chris Cannam |
---|---|
date | Wed, 14 Jan 2015 10:36:55 +0000 |
parents | 2437c52b4d62 |
children | 61701d895082 |
files | test/test_process.py vamp/__init__.py |
diffstat | 2 files changed, 30 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /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
--- 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 +