Mercurial > hg > vampy-host
comparison vamp/collect.py @ 111:4f590fc46ace
Update tests
author | Chris Cannam |
---|---|
date | Wed, 17 Jun 2015 11:04:15 +0100 |
parents | 0c5a4dc04ed9 |
children | 9343eee50605 |
comparison
equal
deleted
inserted
replaced
110:6c8ce9a97e8b | 111:4f590fc46ace |
---|---|
6 import frames | 6 import frames |
7 | 7 |
8 import numpy as np | 8 import numpy as np |
9 | 9 |
10 def get_feature_step_time(sample_rate, step_size, output_desc): | 10 def get_feature_step_time(sample_rate, step_size, output_desc): |
11 if output_desc["sample_type"] == vampyhost.ONE_SAMPLE_PER_STEP: | 11 if output_desc["sampleType"] == vampyhost.ONE_SAMPLE_PER_STEP: |
12 return vampyhost.frame_to_realtime(step_size, sample_rate) | 12 return vampyhost.frame_to_realtime(step_size, sample_rate) |
13 elif output_desc["sample_type"] == vampyhost.FIXED_SAMPLE_RATE: | 13 elif output_desc["sampleType"] == vampyhost.FIXED_SAMPLE_RATE: |
14 return vampyhost.RealTime('seconds', 1.0 / output_desc["sample_rate"]) | 14 return vampyhost.RealTime('seconds', 1.0 / output_desc["sampleRate"]) |
15 else: | 15 else: |
16 return 1 | 16 return 1 |
17 | 17 |
18 def timestamp_features(sample_rate, step_size, output_desc, features): | 18 def timestamp_features(sample_rate, step_size, output_desc, features): |
19 n = -1 | 19 n = -1 |
20 if output_desc["sample_type"] == vampyhost.ONE_SAMPLE_PER_STEP: | 20 if output_desc["sampleType"] == vampyhost.ONE_SAMPLE_PER_STEP: |
21 for f in features: | 21 for f in features: |
22 n = n + 1 | 22 n = n + 1 |
23 t = vampyhost.frame_to_realtime(n * step_size, sample_rate) | 23 t = vampyhost.frame_to_realtime(n * step_size, sample_rate) |
24 f["timestamp"] = t | 24 f["timestamp"] = t |
25 yield f | 25 yield f |
26 elif output_desc["sample_type"] == vampyhost.FIXED_SAMPLE_RATE: | 26 elif output_desc["sampleType"] == vampyhost.FIXED_SAMPLE_RATE: |
27 output_rate = output_desc["sample_rate"] | 27 output_rate = output_desc["sampleRate"] |
28 for f in features: | 28 for f in features: |
29 if "has_timestamp" in f: | 29 if "has_timestamp" in f: |
30 n = int(f["timestamp"].to_float() * output_rate + 0.5) | 30 n = int(f["timestamp"].to_float() * output_rate + 0.5) |
31 else: | 31 else: |
32 n = n + 1 | 32 n = n + 1 |
46 | 46 |
47 for s in stamped: | 47 for s in stamped: |
48 yield s | 48 yield s |
49 | 49 |
50 def deduce_shape(output_desc): | 50 def deduce_shape(output_desc): |
51 if output_desc["has_duration"]: | 51 if output_desc["hasDuration"]: |
52 return "individual" | 52 return "individual" |
53 if output_desc["sample_type"] == vampyhost.VARIABLE_SAMPLE_RATE: | 53 if output_desc["sampleType"] == vampyhost.VARIABLE_SAMPLE_RATE: |
54 return "individual" | 54 return "individual" |
55 if not output_desc["has_fixed_bin_count"]: | 55 if not output_desc["hasFixedBinCount"]: |
56 return "individual" | 56 return "individual" |
57 if output_desc["bin_count"] == 0: | 57 if output_desc["binCount"] == 0: |
58 return "individual" | 58 return "individual" |
59 if output_desc["bin_count"] == 1: | 59 if output_desc["binCount"] == 1: |
60 return "vector" | 60 return "vector" |
61 return "matrix" | 61 return "matrix" |
62 | 62 |
63 | 63 |
64 def reshape(results, sample_rate, step_size, output_desc): | 64 def reshape(results, sample_rate, step_size, output_desc): |