Mercurial > hg > qm-vamp-plugins
changeset 32:8cde4a0f36ef
* Permit onset detector to use different step and block sizes from preferred
(this produces wrong results for the beat tracker, but not onset detector)
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 09 Nov 2007 17:03:58 +0000 |
parents | 5cd7e3069553 |
children | 7359cda467c3 |
files | plugins/OnsetDetect.cpp plugins/OnsetDetect.h |
diffstat | 2 files changed, 10 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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);