From: Paul Brossier Date: Wed, 17 May 2006 15:15:12 +0000 (+0000) Subject: set negative timestamps to zero X-Git-Tag: hgimport~45 X-Git-Url: https://git.aubio.org/?p=vamp-aubio-plugins.git;a=commitdiff_plain;h=bc6722042486cce45f2f552238f4f45ab3e2a830 set negative timestamps to zero --- diff --git a/plugins/Notes.cpp b/plugins/Notes.cpp index 05f7189..39ad0f2 100644 --- a/plugins/Notes.cpp +++ b/plugins/Notes.cpp @@ -112,6 +112,8 @@ Notes::initialise(size_t channels, size_t stepSize, size_t blockSize) m_pitchmode); m_count = 0; + m_delay = Vamp::RealTime::frame2RealTime((4 + m_median) * m_stepSize, + lrintf(m_inputSampleRate)); m_currentOnset = Vamp::RealTime::zeroTime; m_haveCurrent = false; @@ -324,9 +326,8 @@ Notes::pushNote(FeatureSet &fs, const Vamp::RealTime &offTime) Feature feature; feature.hasTimestamp = true; - feature.timestamp = m_currentOnset - - Vamp::RealTime::frame2RealTime((4 + m_median) * m_stepSize, - m_inputSampleRate); + if (m_currentOnset < m_delay) m_currentOnset = m_delay; + feature.timestamp = m_currentOnset - m_delay; feature.values.push_back(median); // feature.values.push_back(FLOOR(aubio_freqtomidi(median) + 0.5)); feature.values.push_back diff --git a/plugins/Notes.h b/plugins/Notes.h index 3f86bce..cb28230 100644 --- a/plugins/Notes.h +++ b/plugins/Notes.h @@ -71,6 +71,7 @@ protected: size_t m_channelCount; std::deque m_notebuf; size_t m_count; + Vamp::RealTime m_delay; Vamp::RealTime m_currentOnset; Vamp::RealTime m_lastTimeStamp; float m_currentLevel; diff --git a/plugins/Onset.cpp b/plugins/Onset.cpp index def541f..3771af1 100644 --- a/plugins/Onset.cpp +++ b/plugins/Onset.cpp @@ -250,6 +250,7 @@ Onset::process(float **inputBuffers, Vamp::RealTime timestamp) if (timestamp - m_lastOnset >= m_delay) { Feature onsettime; onsettime.hasTimestamp = true; + if (timestamp < m_delay) timestamp = m_delay; onsettime.timestamp = timestamp - m_delay; returnFeatures[0].push_back(onsettime); m_lastOnset = timestamp;