# HG changeset patch # User Chris Cannam # Date 1746520974 -3600 # Tue May 06 09:42:54 2025 +0100 # Branch higher-precision # Node ID 1bd6f905377d993a40f4a084659c5232fce46324 # Parent 6315e71af3b4c0555f9b7e66c5b30ff5795809d4 Add candidates output diff --git a/vamp/Makefile b/vamp/Makefile --- a/vamp/Makefile +++ b/vamp/Makefile @@ -7,7 +7,7 @@ MINIBPM_SOURCES := ../src/MiniBpm.cpp MINIBPM_HEADERS := ../src/MiniBpm.h -CXXFLAGS := -I../src -fPIC +CXXFLAGS := -std=c++98 -I../src -fPIC VAMP_LDFLAGS := $(LDFLAGS) $(PLUGIN_LDFLAGS) -lvamp-sdk diff --git a/vamp/MiniBpmVamp.cpp b/vamp/MiniBpmVamp.cpp --- a/vamp/MiniBpmVamp.cpp +++ b/vamp/MiniBpmVamp.cpp @@ -71,7 +71,7 @@ { // Increment this each time you release a version that behaves // differently from the previous one - return 1; + return 2; } string @@ -189,6 +189,18 @@ d.hasDuration = true; outputs.push_back(d); + d = OutputDescriptor(); + d.identifier = "candidates"; + d.name = "Tempo Candidates"; + d.description = "A multi-valued feature containing all tempo candidates starting with the most likely"; + d.hasFixedBinCount = false; + d.hasKnownExtents = false; + d.isQuantized = false; + d.sampleType = OutputDescriptor::FixedSampleRate; + d.sampleRate = m_inputSampleRate; + d.hasDuration = true; + outputs.push_back(d); + return outputs; } @@ -210,12 +222,14 @@ { m_mbpm->reset(); m_mbpm->setBeatsPerBar(m_beatsPerBar); + m_lastTimestamp = Vamp::RealTime::zeroTime; } MiniBpmVamp::FeatureSet MiniBpmVamp::process(const float *const *inputBuffers, Vamp::RealTime timestamp) { m_mbpm->process(inputBuffers[0], m_blockSize); + m_lastTimestamp = timestamp; return FeatureSet(); } @@ -230,10 +244,24 @@ f.hasTimestamp = true; f.timestamp = Vamp::RealTime::zeroTime; f.hasDuration = true; - f.duration = Vamp::RealTime::fromSeconds(1.0); + f.duration = m_lastTimestamp + + Vamp::RealTime::frame2RealTime(m_blockSize, m_inputSampleRate); f.values.push_back(bpm); fs[0].push_back(f); + std::vector candidates = m_mbpm->getTempoCandidates(); + + f = Feature(); + f.hasTimestamp = true; + f.timestamp = Vamp::RealTime::zeroTime; + f.hasDuration = true; + f.duration = m_lastTimestamp + + Vamp::RealTime::frame2RealTime(m_blockSize, m_inputSampleRate); + for (size_t i = 0; i < candidates.size(); ++i) { + f.values.push_back(candidates[i]); + } + fs[1].push_back(f); + return fs; } diff --git a/vamp/MiniBpmVamp.h b/vamp/MiniBpmVamp.h --- a/vamp/MiniBpmVamp.h +++ b/vamp/MiniBpmVamp.h @@ -72,6 +72,7 @@ protected: breakfastquay::MiniBPM *m_mbpm; + Vamp::RealTime m_lastTimestamp; size_t m_blockSize; int m_beatsPerBar; };