# HG changeset patch # User Chris Cannam # Date 1194627838 0 # Node ID 8cde4a0f36ef86367da8d2842c6e156db0c57fc0 # Parent 5cd7e3069553150c3e3fb4a9f97acee9a344265f * Permit onset detector to use different step and block sizes from preferred (this produces wrong results for the beat tracker, but not onset detector) diff -r 5cd7e3069553 -r 8cde4a0f36ef plugins/OnsetDetect.cpp --- a/plugins/OnsetDetect.cpp Mon Sep 03 13:37:25 2007 +0000 +++ b/plugins/OnsetDetect.cpp Fri Nov 09 17:03:58 2007 +0000 @@ -18,7 +18,7 @@ using std::cerr; using std::endl; -float OnsetDetector::m_stepSecs = 0.01161; +float OnsetDetector::m_preferredStepSecs = 0.01161; class OnsetDetectorData { @@ -238,15 +238,13 @@ } if (stepSize != getPreferredStepSize()) { - std::cerr << "ERROR: OnsetDetector::initialise: Unsupported step size for this sample rate: " + std::cerr << "WARNING: OnsetDetector::initialise: Possibly sub-optimal step size for this sample rate: " << stepSize << " (wanted " << (getPreferredStepSize()) << ")" << std::endl; - return false; } if (blockSize != getPreferredBlockSize()) { - std::cerr << "WARNING: OnsetDetector::initialise: Sub-optimal block size for this sample rate: " + std::cerr << "WARNING: OnsetDetector::initialise: Possibly sub-optimal block size for this sample rate: " << blockSize << " (wanted " << (getPreferredBlockSize()) << ")" << std::endl; -// return false; } DFConfig dfConfig; @@ -272,7 +270,7 @@ size_t OnsetDetector::getPreferredStepSize() const { - size_t step = size_t(m_inputSampleRate * m_stepSecs + 0.0001); + size_t step = size_t(m_inputSampleRate * m_preferredStepSecs + 0.0001); // std::cerr << "OnsetDetector::getPreferredStepSize: input sample rate is " << m_inputSampleRate << ", step size is " << step << std::endl; return step; } @@ -288,6 +286,9 @@ { OutputList list; + float stepSecs = m_preferredStepSecs; + if (m_d) stepSecs = m_d->dfConfig.stepSecs; + OutputDescriptor onsets; onsets.identifier = "onsets"; onsets.name = "Note Onsets"; @@ -296,7 +297,7 @@ onsets.hasFixedBinCount = true; onsets.binCount = 0; onsets.sampleType = OutputDescriptor::VariableSampleRate; - onsets.sampleRate = 1.0 / m_stepSecs; + onsets.sampleRate = 1.0 / stepSecs; OutputDescriptor df; df.identifier = "detection_fn"; @@ -323,7 +324,7 @@ //!!! SV doesn't seem to handle these correctly in getRemainingFeatures // sdf.sampleType = OutputDescriptor::FixedSampleRate; - sdf.sampleRate = 1.0 / m_stepSecs; + sdf.sampleRate = 1.0 / stepSecs; list.push_back(onsets); list.push_back(df); diff -r 5cd7e3069553 -r 8cde4a0f36ef plugins/OnsetDetect.h --- a/plugins/OnsetDetect.h Mon Sep 03 13:37:25 2007 +0000 +++ b/plugins/OnsetDetect.h Fri Nov 09 17:03:58 2007 +0000 @@ -56,7 +56,7 @@ float m_sensitivity; bool m_whiten; std::string m_program; - static float m_stepSecs; + static float m_preferredStepSecs; };