Mercurial > hg > vamp-aubio-plugins
changeset 3:4bfe0cf6e20a
* Compensate for 4*stepSize delay in onset detection with returned timestamps
* Discard onsets that occur within 4*stepSize of previous onset
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Wed, 17 May 2006 10:02:36 +0000 |
parents | 76c1a7bd0416 |
children | be376e1b36c3 |
files | plugins/Onset.cpp plugins/Onset.h |
diffstat | 2 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/Onset.cpp Tue May 16 15:43:21 2006 +0000 +++ b/plugins/Onset.cpp Wed May 17 10:02:36 2006 +0000 @@ -91,6 +91,11 @@ m_peakpick = new_aubio_peakpicker(m_threshold); m_onsetdet = new_aubio_onsetdetection(m_onsettype, blockSize, channels); + + m_delay = Vamp::RealTime::frame2RealTime(4 * stepSize, + lrintf(m_inputSampleRate)); + + m_lastOnset = Vamp::RealTime::zeroTime - m_delay - m_delay; return true; } @@ -109,7 +114,7 @@ size_t Onset::getPreferredBlockSize() const { - return 2*getPreferredStepSize(); + return 2 * getPreferredStepSize(); } Onset::ParameterList @@ -201,7 +206,8 @@ d.description = "Onsets"; d.hasFixedBinCount = true; d.binCount = 0; - d.sampleType = OutputDescriptor::OneSamplePerStep; + d.sampleType = OutputDescriptor::VariableSampleRate; + d.sampleRate = 0; list.push_back(d); d = OutputDescriptor(); @@ -219,7 +225,7 @@ } Onset::FeatureSet -Onset::process(float **inputBuffers, Vamp::RealTime /* timestamp */) +Onset::process(float **inputBuffers, Vamp::RealTime timestamp) { for (size_t i = 0; i < m_stepSize; ++i) { for (size_t j = 0; j < m_channelCount; ++j) { @@ -241,9 +247,13 @@ FeatureSet returnFeatures; if (isonset) { - Feature onsettime; - onsettime.hasTimestamp = false; - returnFeatures[0].push_back(onsettime); + if (timestamp - m_lastOnset >= m_delay) { + Feature onsettime; + onsettime.hasTimestamp = true; + onsettime.timestamp = timestamp - m_delay; + returnFeatures[0].push_back(onsettime); + m_lastOnset = timestamp; + } } Feature feature; for (size_t j = 0; j < m_channelCount; ++j) {