set negative timestamps to zero
authorPaul Brossier <piem@piem.org>
Wed, 17 May 2006 15:15:12 +0000 (15:15 +0000)
committerPaul Brossier <piem@piem.org>
Wed, 17 May 2006 15:15:12 +0000 (15:15 +0000)
plugins/Notes.cpp
plugins/Notes.h
plugins/Onset.cpp

index 05f7189..39ad0f2 100644 (file)
@@ -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
index 3f86bce..cb28230 100644 (file)
@@ -71,6 +71,7 @@ protected:
     size_t m_channelCount;
     std::deque<float> m_notebuf;
     size_t m_count;
+    Vamp::RealTime m_delay;
     Vamp::RealTime m_currentOnset;
     Vamp::RealTime m_lastTimeStamp;
     float m_currentLevel;
index def541f..3771af1 100644 (file)
@@ -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;