Mercurial > hg > beatroot-vamp
comparison BeatRootVampPlugin.cpp @ 31:b9c2f444cdaa
Fix incorrect return timestamps when run with non-zero origin time
author | Chris Cannam |
---|---|
date | Fri, 06 Dec 2013 14:38:17 +0000 |
parents | 633ec097fa56 |
children | 937432fc2898 |
comparison
equal
deleted
inserted
replaced
30:eeafdd147988 | 31:b9c2f444cdaa |
---|---|
20 | 20 |
21 #include <vamp-sdk/RealTime.h> | 21 #include <vamp-sdk/RealTime.h> |
22 #include <vamp-sdk/PluginAdapter.h> | 22 #include <vamp-sdk/PluginAdapter.h> |
23 | 23 |
24 BeatRootVampPlugin::BeatRootVampPlugin(float inputSampleRate) : | 24 BeatRootVampPlugin::BeatRootVampPlugin(float inputSampleRate) : |
25 Plugin(inputSampleRate) | 25 Plugin(inputSampleRate), |
26 m_firstFrame(true) | |
26 { | 27 { |
27 m_processor = new BeatRootProcessor(inputSampleRate, AgentParameters()); | 28 m_processor = new BeatRootProcessor(inputSampleRate, AgentParameters()); |
28 } | 29 } |
29 | 30 |
30 BeatRootVampPlugin::~BeatRootVampPlugin() | 31 BeatRootVampPlugin::~BeatRootVampPlugin() |
105 { | 106 { |
106 ParameterList list; | 107 ParameterList list; |
107 | 108 |
108 ParameterDescriptor desc; | 109 ParameterDescriptor desc; |
109 | 110 |
110 double postMarginFactor; | |
111 | |
112 /** The maximum amount by which a beat can be earlier than the | |
113 * predicted beat time, expressed as a fraction of the beat | |
114 * period. */ | |
115 double preMarginFactor; | |
116 | |
117 /** The maximum allowed deviation from the initial tempo, | |
118 * expressed as a fraction of the initial beat period. */ | |
119 double maxChange; | |
120 | |
121 /** The default value of expiryTime, which is the time (in | |
122 * seconds) after which an Agent that has no Event matching its | |
123 * beat predictions will be destroyed. */ | |
124 | |
125 desc.identifier = "preMarginFactor"; | 111 desc.identifier = "preMarginFactor"; |
126 desc.name = "Pre-Margin Factor"; | 112 desc.name = "Pre-Margin Factor"; |
127 desc.description = "The maximum amount by which a beat can be earlier than the predicted beat time, expressed as a fraction of the beat period."; | 113 desc.description = "The maximum amount by which a beat can be earlier than the predicted beat time, expressed as a fraction of the beat period."; |
128 desc.minValue = 0; | 114 desc.minValue = 0; |
129 desc.maxValue = 1; | 115 desc.maxValue = 1; |
293 | 279 |
294 void | 280 void |
295 BeatRootVampPlugin::reset() | 281 BeatRootVampPlugin::reset() |
296 { | 282 { |
297 m_processor->reset(); | 283 m_processor->reset(); |
284 m_firstFrame = true; | |
285 m_origin = Vamp::RealTime::zeroTime; | |
298 } | 286 } |
299 | 287 |
300 BeatRootVampPlugin::FeatureSet | 288 BeatRootVampPlugin::FeatureSet |
301 BeatRootVampPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp) | 289 BeatRootVampPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp) |
302 { | 290 { |
291 if (m_firstFrame) { | |
292 m_origin = timestamp; | |
293 m_firstFrame = false; | |
294 } | |
295 | |
303 m_processor->processFrame(inputBuffers); | 296 m_processor->processFrame(inputBuffers); |
304 return FeatureSet(); | 297 return FeatureSet(); |
305 } | 298 } |
306 | 299 |
307 BeatRootVampPlugin::FeatureSet | 300 BeatRootVampPlugin::FeatureSet |
316 f.values.clear(); | 309 f.values.clear(); |
317 | 310 |
318 FeatureSet fs; | 311 FeatureSet fs; |
319 | 312 |
320 for (EventList::const_iterator i = el.begin(); i != el.end(); ++i) { | 313 for (EventList::const_iterator i = el.begin(); i != el.end(); ++i) { |
321 f.timestamp = Vamp::RealTime::fromSeconds(i->time); | 314 f.timestamp = m_origin + Vamp::RealTime::fromSeconds(i->time); |
322 fs[0].push_back(f); | 315 fs[0].push_back(f); |
323 } | 316 } |
324 | 317 |
325 return fs; | 318 return fs; |
326 } | 319 } |