Mercurial > hg > qm-vamp-plugins
changeset 18:99dadc93042e
* Adapt to Vamp API update
* Add an output for locked tempo from beat detector
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 08 Dec 2006 18:06:35 +0000 |
parents | d4a92aab8147 |
children | 799b13ab3792 |
files | plugins/BeatDetect.cpp plugins/BeatDetect.h plugins/ChromagramPlugin.cpp plugins/ChromagramPlugin.h plugins/ConstantQSpectrogram.cpp plugins/ConstantQSpectrogram.h plugins/TonalChangeDetect.cpp plugins/TonalChangeDetect.h |
diffstat | 8 files changed, 46 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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<int> beats = tempoTracker.process(m_d->dfOutput); + vector<double> tempos; + vector<int> 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; }
--- 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();
--- 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: "
--- 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();
--- 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: "
--- 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();
--- 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: "
--- 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();