Mercurial > hg > vamp-test-plugin
comparison VampTestPlugin.cpp @ 20:cfff2b6ff0fd
Add timestamp output and frequency-domain version
author | Chris Cannam |
---|---|
date | Wed, 14 Jan 2015 10:55:32 +0000 |
parents | 534b001d8e8f |
children | 8984ab4a0213 |
comparison
equal
deleted
inserted
replaced
19:534b001d8e8f | 20:cfff2b6ff0fd |
---|---|
8 | 8 |
9 using namespace std; | 9 using namespace std; |
10 | 10 |
11 using Vamp::RealTime; | 11 using Vamp::RealTime; |
12 | 12 |
13 VampTestPlugin::VampTestPlugin(float inputSampleRate) : | 13 VampTestPlugin::VampTestPlugin(float inputSampleRate, bool freq) : |
14 Plugin(inputSampleRate), | 14 Plugin(inputSampleRate), |
15 m_frequencyDomain(freq), | |
15 m_produceOutput(true), | 16 m_produceOutput(true), |
16 m_n(0), | 17 m_n(0), |
17 m_channels(1), | 18 m_channels(1), |
18 m_stepSize(0), | 19 m_stepSize(0), |
19 m_blockSize(0) | 20 m_blockSize(0) |
28 } | 29 } |
29 | 30 |
30 string | 31 string |
31 VampTestPlugin::getIdentifier() const | 32 VampTestPlugin::getIdentifier() const |
32 { | 33 { |
33 return "vamp-test-plugin"; | 34 if (m_frequencyDomain) { |
35 return "vamp-test-plugin-freq"; | |
36 } else { | |
37 return "vamp-test-plugin"; | |
38 } | |
34 } | 39 } |
35 | 40 |
36 string | 41 string |
37 VampTestPlugin::getName() const | 42 VampTestPlugin::getName() const |
38 { | 43 { |
39 return "Vamp Test Plugin"; | 44 if (m_frequencyDomain) { |
45 return "Vamp Test Plugin (Frequency-Domain Input)"; | |
46 } else { | |
47 return "Vamp Test Plugin"; | |
48 } | |
40 } | 49 } |
41 | 50 |
42 string | 51 string |
43 VampTestPlugin::getDescription() const | 52 VampTestPlugin::getDescription() const |
44 { | 53 { |
52 } | 61 } |
53 | 62 |
54 int | 63 int |
55 VampTestPlugin::getPluginVersion() const | 64 VampTestPlugin::getPluginVersion() const |
56 { | 65 { |
57 return 2; | 66 return 3; |
58 } | 67 } |
59 | 68 |
60 string | 69 string |
61 VampTestPlugin::getCopyright() const | 70 VampTestPlugin::getCopyright() const |
62 { | 71 { |
64 } | 73 } |
65 | 74 |
66 VampTestPlugin::InputDomain | 75 VampTestPlugin::InputDomain |
67 VampTestPlugin::getInputDomain() const | 76 VampTestPlugin::getInputDomain() const |
68 { | 77 { |
69 return TimeDomain; | 78 return m_frequencyDomain ? FrequencyDomain : TimeDomain; |
70 } | 79 } |
71 | 80 |
72 size_t | 81 size_t |
73 VampTestPlugin::getPreferredBlockSize() const | 82 VampTestPlugin::getPreferredBlockSize() const |
74 { | 83 { |
280 d.sampleType = OutputDescriptor::OneSamplePerStep; | 289 d.sampleType = OutputDescriptor::OneSamplePerStep; |
281 d.hasDuration = false; | 290 d.hasDuration = false; |
282 m_outputNumbers[d.identifier] = n++; | 291 m_outputNumbers[d.identifier] = n++; |
283 list.push_back(d); | 292 list.push_back(d); |
284 | 293 |
294 d.identifier = "input-timestamp"; | |
295 d.name = "Input timestamp"; | |
296 d.description = "One-sample-per-step features with one value, containing the time in seconds converted from the timestamp of the corresponding process input block."; | |
297 d.unit = "s"; | |
298 d.hasFixedBinCount = true; | |
299 d.binCount = 1; | |
300 d.hasKnownExtents = false; | |
301 d.isQuantized = false; | |
302 d.sampleType = OutputDescriptor::OneSamplePerStep; | |
303 d.hasDuration = false; | |
304 m_outputNumbers[d.identifier] = n++; | |
305 list.push_back(d); | |
306 | |
285 return list; | 307 return list; |
286 } | 308 } |
287 | 309 |
288 bool | 310 bool |
289 VampTestPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize) | 311 VampTestPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize) |
497 if (inputBuffers[c][i] != 0.f) sum += 1; | 519 if (inputBuffers[c][i] != 0.f) sum += 1; |
498 } | 520 } |
499 f.values.push_back(sum); | 521 f.values.push_back(sum); |
500 } | 522 } |
501 fs[m_outputNumbers["input-summary"]].push_back(f); | 523 fs[m_outputNumbers["input-summary"]].push_back(f); |
524 | |
525 f.values.clear(); | |
526 f.values.push_back(float(timestamp / RealTime(1, 0))); | |
527 fs[m_outputNumbers["input-timestamp"]].push_back(f); | |
502 | 528 |
503 return fs; | 529 return fs; |
504 } | 530 } |
505 | 531 |
506 VampTestPlugin::FeatureSet | 532 VampTestPlugin::FeatureSet |