Mercurial > hg > vampy-host
comparison test/test_collect.py @ 92:18b412a9c4d5
Tests for timestamp filling
author | Chris Cannam |
---|---|
date | Mon, 26 Jan 2015 12:28:30 +0000 |
parents | 7228921e8425 |
children | 4bed6bf67243 |
comparison
equal
deleted
inserted
replaced
91:917e3e2ef2ee | 92:18b412a9c4d5 |
---|---|
12 # for the frequency-domain one. That is certainly expected to be the norm for a | 12 # for the frequency-domain one. That is certainly expected to be the norm for a |
13 # plugin like this that declares no preference, and the Python Vamp module is | 13 # plugin like this that declares no preference, and the Python Vamp module is |
14 # expected to follow the norm | 14 # expected to follow the norm |
15 | 15 |
16 blocksize = 1024 | 16 blocksize = 1024 |
17 eps = 1e-6 | |
17 | 18 |
18 def input_data(n): | 19 def input_data(n): |
19 # start at 1, not 0 so that all elts are non-zero | 20 # start at 1, not 0 so that all elts are non-zero |
20 return np.arange(n) + 1 | 21 return np.arange(n) + 1 |
21 | 22 |
29 results = list(vamp.collect(buf, rate, plugin_key, "input-timestamp")) | 30 results = list(vamp.collect(buf, rate, plugin_key, "input-timestamp")) |
30 assert len(results) == 10 | 31 assert len(results) == 10 |
31 for r in results: | 32 for r in results: |
32 assert r["timestamp"] == vamp.vampyhost.frame_to_realtime(r["values"][0], rate) | 33 assert r["timestamp"] == vamp.vampyhost.frame_to_realtime(r["values"][0], rate) |
33 | 34 |
35 def test_collect_fixed_sample_rate(): | |
36 buf = input_data(blocksize * 10) | |
37 results = list(vamp.collect(buf, rate, plugin_key, "curve-fsr")) | |
38 assert len(results) == 10 | |
39 i = 0 | |
40 for r in results: | |
41 assert r["timestamp"] == vamp.vampyhost.RealTime('seconds', i * 0.4) | |
42 assert abs(r["values"][0] - i * 0.1) < eps | |
43 i = i + 1 | |
44 | |
45 def test_collect_fixed_sample_rate_2(): | |
46 buf = input_data(blocksize * 10) | |
47 results = list(vamp.collect(buf, rate, plugin_key, "curve-fsr-timed")) | |
48 assert len(results) == 10 | |
49 i = 0 | |
50 for r in results: | |
51 assert r["timestamp"] == vamp.vampyhost.RealTime('seconds', i * 0.4) | |
52 assert abs(r["values"][0] - i * 0.1) < eps | |
53 i = i + 1 | |
54 | |
55 def test_collect_variable_sample_rate(): | |
56 buf = input_data(blocksize * 10) | |
57 results = list(vamp.collect(buf, rate, plugin_key, "curve-vsr")) | |
58 assert len(results) == 10 | |
59 i = 0 | |
60 for r in results: | |
61 assert r["timestamp"] == vamp.vampyhost.RealTime('seconds', i * 0.75) | |
62 assert abs(r["values"][0] - i * 0.1) < eps | |
63 i = i + 1 |