Mercurial > hg > vampy-host
comparison test/test_collect.py @ 94:c3318a95625b
Return step as well
author | Chris Cannam |
---|---|
date | Mon, 02 Feb 2015 16:32:44 +0000 |
parents | 4bed6bf67243 |
children | f0e005248b9a |
comparison
equal
deleted
inserted
replaced
93:4bed6bf67243 | 94:c3318a95625b |
---|---|
20 # 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 |
21 return np.arange(n) + 1 | 21 return np.arange(n) + 1 |
22 | 22 |
23 def test_collect_runs_at_all(): | 23 def test_collect_runs_at_all(): |
24 buf = input_data(blocksize * 10) | 24 buf = input_data(blocksize * 10) |
25 results = list(vamp.collect(buf, rate, plugin_key, "input-timestamp")) | 25 step, results = vamp.collect(buf, rate, plugin_key, "input-timestamp") |
26 assert results != [] | 26 assert results != [] |
27 | 27 |
28 def test_collect_one_sample_per_step(): | 28 def test_collect_one_sample_per_step(): |
29 buf = input_data(blocksize * 10) | 29 buf = input_data(blocksize * 10) |
30 results = list(vamp.collect(buf, rate, plugin_key, "input-timestamp")) | 30 step, results = vamp.collect(buf, rate, plugin_key, "input-timestamp") |
31 assert abs(float(step) - (1024.0 / rate)) < eps | |
31 assert len(results) == 10 | 32 assert len(results) == 10 |
32 for i in range(len(results)): | 33 for i in range(len(results)): |
33 # The timestamp should be the frame number of the first frame in the | 34 # The timestamp should be the frame number of the first frame in the |
34 # input buffer | 35 # input buffer |
35 expected = i * blocksize | 36 expected = i * blocksize |
36 actual = results[i] | 37 actual = results[i] |
37 assert actual == expected | 38 assert actual == expected |
38 | 39 |
39 def test_collect_fixed_sample_rate(): | 40 def test_collect_fixed_sample_rate(): |
40 buf = input_data(blocksize * 10) | 41 buf = input_data(blocksize * 10) |
41 results = list(vamp.collect(buf, rate, plugin_key, "curve-fsr")) | 42 step, results = vamp.collect(buf, rate, plugin_key, "curve-fsr") |
43 assert abs(float(step) - 0.4) < eps | |
42 assert len(results) == 10 | 44 assert len(results) == 10 |
43 for i in range(len(results)): | 45 for i in range(len(results)): |
44 assert abs(results[i] - i * 0.1) < eps | 46 assert abs(results[i] - i * 0.1) < eps |
45 | 47 |
46 def test_collect_fixed_sample_rate_2(): | 48 def test_collect_fixed_sample_rate_2(): |
47 buf = input_data(blocksize * 10) | 49 buf = input_data(blocksize * 10) |
48 results = list(vamp.collect(buf, rate, plugin_key, "curve-fsr-timed")) | 50 step, results = vamp.collect(buf, rate, plugin_key, "curve-fsr-timed") |
51 assert abs(float(step) - 0.4) < eps | |
49 assert len(results) == 10 | 52 assert len(results) == 10 |
50 for i in range(len(results)): | 53 for i in range(len(results)): |
51 assert abs(results[i] - i * 0.1) < eps | 54 assert abs(results[i] - i * 0.1) < eps |
52 | 55 |
53 def test_collect_variable_sample_rate(): | 56 def test_collect_variable_sample_rate(): |
54 buf = input_data(blocksize * 10) | 57 buf = input_data(blocksize * 10) |
55 results = list(vamp.collect(buf, rate, plugin_key, "curve-vsr")) | 58 results = vamp.collect(buf, rate, plugin_key, "curve-vsr") |
56 assert len(results) == 10 | 59 assert len(results) == 10 |
57 i = 0 | 60 i = 0 |
58 for r in results: | 61 for r in results: |
59 assert r["timestamp"] == vamp.vampyhost.RealTime('seconds', i * 0.75) | 62 assert r["timestamp"] == vamp.vampyhost.RealTime('seconds', i * 0.75) |
60 assert abs(r["values"][0] - i * 0.1) < eps | 63 assert abs(r["values"][0] - i * 0.1) < eps |