annotate test/test_collect.py @ 88:7228921e8425

Some way to implementing collect()
author Chris Cannam
date Wed, 21 Jan 2015 15:13:00 +0000
parents 78844c4b329c
children 18b412a9c4d5
rev   line source
Chris@71 1
Chris@71 2 import vamp
Chris@71 3 import numpy as np
Chris@71 4
Chris@82 5 plugin_key = "vamp-test-plugin:vamp-test-plugin"
Chris@82 6 plugin_key_freq = "vamp-test-plugin:vamp-test-plugin-freq"
Chris@71 7
Chris@71 8 rate = 44100
Chris@71 9
Chris@71 10 # Throughout this file we have the assumption that the plugin gets run with a
Chris@71 11 # blocksize of 1024, and with a step of 1024 for the time-domain version or 512
Chris@71 12 # for the frequency-domain one. That is certainly expected to be the norm for a
Chris@71 13 # plugin like this that declares no preference, and the Python Vamp module is
Chris@71 14 # expected to follow the norm
Chris@71 15
Chris@71 16 blocksize = 1024
Chris@71 17
Chris@71 18 def input_data(n):
Chris@71 19 # start at 1, not 0 so that all elts are non-zero
Chris@71 20 return np.arange(n) + 1
Chris@71 21
Chris@71 22 def test_collect_runs_at_all():
Chris@88 23 buf = input_data(blocksize * 10)
Chris@88 24 results = list(vamp.collect(buf, rate, plugin_key, "input-timestamp"))
Chris@88 25 assert results != []
Chris@88 26
Chris@88 27 def test_collect_one_sample_per_step():
Chris@88 28 buf = input_data(blocksize * 10)
Chris@88 29 results = list(vamp.collect(buf, rate, plugin_key, "input-timestamp"))
Chris@88 30 assert len(results) == 10
Chris@88 31 for r in results:
Chris@88 32 assert r["timestamp"] == vamp.vampyhost.frame_to_realtime(r["values"][0], rate)
Chris@88 33