Implement reset functions (fixes #498)
[vamp-aubio-plugins.git] / plugins / Tempo.cpp
index 82c38f8..ac106c3 100644 (file)
@@ -94,23 +94,26 @@ Tempo::initialise(size_t channels, size_t stepSize, size_t blockSize)
     m_delay = Vamp::RealTime::frame2RealTime(3 * stepSize,
                                              lrintf(m_inputSampleRate));
 
+    reset();
+
+    return true;
+}
+
+void
+Tempo::reset()
+{
+    if (m_tempo) del_aubio_tempo(m_tempo);
+
     m_lastBeat = Vamp::RealTime::zeroTime - m_delay - m_delay;
 
     m_tempo = new_aubio_tempo
         (const_cast<char *>(getAubioNameForOnsetType(m_onsettype)),
-         blockSize,
-         stepSize,
+         m_blockSize,
+         m_stepSize,
          lrintf(m_inputSampleRate));
 
     aubio_tempo_set_silence(m_tempo, m_silence);
     aubio_tempo_set_threshold(m_tempo, m_threshold);
-
-    return true;
-}
-
-void
-Tempo::reset()
-{
 }
 
 size_t