Mercurial > hg > qm-vamp-plugins
diff plugins/BeatTrack.cpp @ 85:2631d0b3d7eb
* Ensure beat tracker, onset detector & tonal change detector return
results timed from the first input timestamp, not always from zero
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Thu, 04 Dec 2008 12:03:51 +0000 |
parents | 4fe04e706839 |
children | e377296d01b2 |
line wrap: on
line diff
--- a/plugins/BeatTrack.cpp Mon Dec 01 19:55:43 2008 +0000 +++ b/plugins/BeatTrack.cpp Thu Dec 04 12:03:51 2008 +0000 @@ -33,11 +33,13 @@ delete df; df = new DetectionFunction(dfConfig); dfOutput.clear(); + origin = Vamp::RealTime::zeroTime; } DFConfig dfConfig; DetectionFunction *df; vector<double> dfOutput; + Vamp::RealTime origin; }; @@ -272,7 +274,7 @@ BeatTracker::FeatureSet BeatTracker::process(const float *const *inputBuffers, - Vamp::RealTime /* timestamp */) + Vamp::RealTime timestamp) { if (!m_d) { cerr << "ERROR: BeatTracker::process: " @@ -301,6 +303,8 @@ delete[] magnitudes; delete[] phases; + if (m_d->dfOutput.empty()) m_d->origin = timestamp; + m_d->dfOutput.push_back(output); FeatureSet returnFeatures; @@ -351,7 +355,7 @@ Feature feature; feature.hasTimestamp = true; - feature.timestamp = Vamp::RealTime::frame2RealTime + feature.timestamp = m_d->origin + Vamp::RealTime::frame2RealTime (frame, lrintf(m_inputSampleRate)); float bpm = 0.0; @@ -387,7 +391,7 @@ if (tempos[i] > 1 && int(tempos[i] * 100) != int(prevTempo * 100)) { Feature feature; feature.hasTimestamp = true; - feature.timestamp = Vamp::RealTime::frame2RealTime + feature.timestamp = m_d->origin + Vamp::RealTime::frame2RealTime (frame, lrintf(m_inputSampleRate)); feature.values.push_back(tempos[i]); sprintf(label, "%.2f bpm", tempos[i]);