# HG changeset patch # User Chris Cannam # Date 1165601195 0 # Node ID 99dadc93042ec7abaa30b885d89c155a70d7f5b3 # Parent d4a92aab8147fa0f53c641f6eee2c004afc658bd * Adapt to Vamp API update * Add an output for locked tempo from beat detector diff -r d4a92aab8147 -r 99dadc93042e plugins/BeatDetect.cpp --- a/plugins/BeatDetect.cpp Thu Nov 30 14:53:29 2006 +0000 +++ b/plugins/BeatDetect.cpp Fri Dec 08 18:06:35 2006 +0000 @@ -73,7 +73,7 @@ int BeatDetector::getPluginVersion() const { - return 1; + return 2; } string @@ -212,14 +212,25 @@ df.isQuantized = false; df.sampleType = OutputDescriptor::OneSamplePerStep; + OutputDescriptor tempo; + tempo.name = "tempo"; + tempo.unit = "bpm"; + tempo.description = "Tempo"; + tempo.hasFixedBinCount = true; + tempo.binCount = 1; + tempo.sampleType = OutputDescriptor::VariableSampleRate; + tempo.sampleRate = 1.0 / m_stepSecs; + list.push_back(beat); list.push_back(df); + list.push_back(tempo); return list; } BeatDetector::FeatureSet -BeatDetector::process(float **inputBuffers, Vamp::RealTime /* timestamp */) +BeatDetector::process(const float *const *inputBuffers, + Vamp::RealTime /* timestamp */) { if (!m_d) { cerr << "ERROR: BeatDetector::process: " @@ -284,7 +295,8 @@ ttParams.WinT.pre = 7; TempoTrack tempoTracker(ttParams); - vector beats = tempoTracker.process(m_d->dfOutput); + vector tempos; + vector beats = tempoTracker.process(m_d->dfOutput, &tempos); FeatureSet returnFeatures; @@ -320,6 +332,22 @@ returnFeatures[0].push_back(feature); // beats are output 0 } + double prevTempo = 0.0; + + for (size_t i = 0; i < tempos.size(); ++i) { + + size_t frame = i * m_d->dfConfig.stepSize * ttParams.winLength; + + if (tempos[i] > 1 && tempos[i] != prevTempo) { + Feature feature; + feature.hasTimestamp = true; + feature.timestamp = Vamp::RealTime::frame2RealTime + (frame, lrintf(m_inputSampleRate)); + feature.values.push_back(tempos[i]); + returnFeatures[2].push_back(feature); // tempo is output 2 + } + } + return returnFeatures; } diff -r d4a92aab8147 -r 99dadc93042e plugins/BeatDetect.h --- a/plugins/BeatDetect.h Thu Nov 30 14:53:29 2006 +0000 +++ b/plugins/BeatDetect.h Fri Dec 08 18:06:35 2006 +0000 @@ -40,7 +40,8 @@ OutputList getOutputDescriptors() const; - FeatureSet process(float **inputBuffers, Vamp::RealTime timestamp); + FeatureSet process(const float *const *inputBuffers, + Vamp::RealTime timestamp); FeatureSet getRemainingFeatures(); diff -r d4a92aab8147 -r 99dadc93042e plugins/ChromagramPlugin.cpp --- a/plugins/ChromagramPlugin.cpp Thu Nov 30 14:53:29 2006 +0000 +++ b/plugins/ChromagramPlugin.cpp Fri Dec 08 18:06:35 2006 +0000 @@ -309,7 +309,8 @@ } ChromagramPlugin::FeatureSet -ChromagramPlugin::process(float **inputBuffers, Vamp::RealTime /* timestamp */) +ChromagramPlugin::process(const float *const *inputBuffers, + Vamp::RealTime /* timestamp */) { if (!m_chromagram) { cerr << "ERROR: ChromagramPlugin::process: " diff -r d4a92aab8147 -r 99dadc93042e plugins/ChromagramPlugin.h --- a/plugins/ChromagramPlugin.h Thu Nov 30 14:53:29 2006 +0000 +++ b/plugins/ChromagramPlugin.h Fri Dec 08 18:06:35 2006 +0000 @@ -41,7 +41,8 @@ OutputList getOutputDescriptors() const; - FeatureSet process(float **inputBuffers, Vamp::RealTime timestamp); + FeatureSet process(const float *const *inputBuffers, + Vamp::RealTime timestamp); FeatureSet getRemainingFeatures(); diff -r d4a92aab8147 -r 99dadc93042e plugins/ConstantQSpectrogram.cpp --- a/plugins/ConstantQSpectrogram.cpp Thu Nov 30 14:53:29 2006 +0000 +++ b/plugins/ConstantQSpectrogram.cpp Fri Dec 08 18:06:35 2006 +0000 @@ -309,7 +309,8 @@ } ConstantQSpectrogram::FeatureSet -ConstantQSpectrogram::process(float **inputBuffers, Vamp::RealTime /* timestamp */) +ConstantQSpectrogram::process(const float *const *inputBuffers, + Vamp::RealTime /* timestamp */) { if (!m_cq) { cerr << "ERROR: ConstantQSpectrogram::process: " diff -r d4a92aab8147 -r 99dadc93042e plugins/ConstantQSpectrogram.h --- a/plugins/ConstantQSpectrogram.h Thu Nov 30 14:53:29 2006 +0000 +++ b/plugins/ConstantQSpectrogram.h Fri Dec 08 18:06:35 2006 +0000 @@ -41,7 +41,8 @@ OutputList getOutputDescriptors() const; - FeatureSet process(float **inputBuffers, Vamp::RealTime timestamp); + FeatureSet process(const float *const *inputBuffers, + Vamp::RealTime timestamp); FeatureSet getRemainingFeatures(); diff -r d4a92aab8147 -r 99dadc93042e plugins/TonalChangeDetect.cpp --- a/plugins/TonalChangeDetect.cpp Thu Nov 30 14:53:29 2006 +0000 +++ b/plugins/TonalChangeDetect.cpp Fri Dec 08 18:06:35 2006 +0000 @@ -289,7 +289,9 @@ return list; } -TonalChangeDetect::FeatureSet TonalChangeDetect::process(float **inputBuffers, Vamp::RealTime timestamp) +TonalChangeDetect::FeatureSet +TonalChangeDetect::process(const float *const *inputBuffers, + Vamp::RealTime timestamp) { if (!m_chromagram) { cerr << "ERROR: TonalChangeDetect::process: " diff -r d4a92aab8147 -r 99dadc93042e plugins/TonalChangeDetect.h --- a/plugins/TonalChangeDetect.h Thu Nov 30 14:53:29 2006 +0000 +++ b/plugins/TonalChangeDetect.h Fri Dec 08 18:06:35 2006 +0000 @@ -47,7 +47,8 @@ OutputList getOutputDescriptors() const; - FeatureSet process(float **inputBuffers, Vamp::RealTime timestamp); + FeatureSet process(const float *const *inputBuffers, + Vamp::RealTime timestamp); FeatureSet getRemainingFeatures();