# HG changeset patch # User Chris Cannam # Date 1342008555 -3600 # Node ID 119e2255292522eacb187bfa1e18766992e6f102 # Parent 5c5deb8393b94937830585e1bf89288a0b350d09 Implement reset functions (fixes #498) diff -r 5c5deb8393b9 -r 119e22552925 plugins/Notes.cpp --- a/plugins/Notes.cpp Tue Jul 10 17:29:42 2012 +0100 +++ b/plugins/Notes.cpp Wed Jul 11 13:09:15 2012 +0100 @@ -105,10 +105,21 @@ m_onset = new_fvec(1); m_pitch = new_fvec(1); + reset(); + + return true; +} + +void +Notes::reset() +{ + if (m_onsetdet) del_aubio_onset(m_onsetdet); + if (m_pitchdet) del_aubio_pitch(m_pitchdet); + m_onsetdet = new_aubio_onset (const_cast(getAubioNameForOnsetType(m_onsettype)), - blockSize, - stepSize, + m_blockSize, + m_stepSize, lrintf(m_inputSampleRate)); aubio_onset_set_threshold(m_onsetdet, m_threshold); @@ -117,8 +128,8 @@ m_pitchdet = new_aubio_pitch (const_cast(getAubioNameForPitchType(m_pitchtype)), - blockSize, - stepSize, + m_blockSize, + m_stepSize, lrintf(m_inputSampleRate)); aubio_pitch_set_unit(m_pitchdet, const_cast("freq")); @@ -129,13 +140,6 @@ m_currentOnset = Vamp::RealTime::zeroTime; m_haveCurrent = false; m_prevPitch = -1; - - return true; -} - -void -Notes::reset() -{ } size_t diff -r 5c5deb8393b9 -r 119e22552925 plugins/Onset.cpp --- a/plugins/Onset.cpp Tue Jul 10 17:29:42 2012 +0100 +++ b/plugins/Onset.cpp Wed Jul 11 13:09:15 2012 +0100 @@ -91,20 +91,7 @@ m_ibuf = new_fvec(stepSize); m_onset = new_fvec(1); - m_onsetdet = new_aubio_onset - (const_cast(getAubioNameForOnsetType(m_onsettype)), - blockSize, - stepSize, - lrintf(m_inputSampleRate)); - - aubio_onset_set_threshold(m_onsetdet, m_threshold); - aubio_onset_set_silence(m_onsetdet, m_silence); - aubio_onset_set_minioi(m_onsetdet, m_minioi); - - m_delay = Vamp::RealTime::frame2RealTime(4 * stepSize, - lrintf(m_inputSampleRate)); - - m_lastOnset = Vamp::RealTime::zeroTime - m_delay - m_delay; + reset(); return true; } @@ -112,6 +99,22 @@ void Onset::reset() { + if (m_onsetdet) del_aubio_onset(m_onsetdet); + + m_onsetdet = new_aubio_onset + (const_cast(getAubioNameForOnsetType(m_onsettype)), + m_blockSize, + m_stepSize, + lrintf(m_inputSampleRate)); + + aubio_onset_set_threshold(m_onsetdet, m_threshold); + aubio_onset_set_silence(m_onsetdet, m_silence); + aubio_onset_set_minioi(m_onsetdet, m_minioi); + + m_delay = Vamp::RealTime::frame2RealTime(4 * m_stepSize, + lrintf(m_inputSampleRate)); + + m_lastOnset = Vamp::RealTime::zeroTime - m_delay - m_delay; } size_t diff -r 5c5deb8393b9 -r 119e22552925 plugins/Pitch.cpp --- a/plugins/Pitch.cpp Tue Jul 10 17:29:42 2012 +0100 +++ b/plugins/Pitch.cpp Wed Jul 11 13:09:15 2012 +0100 @@ -100,13 +100,7 @@ m_ibuf = new_fvec(stepSize); m_obuf = new_fvec(1); - m_pitchdet = new_aubio_pitch - (const_cast(getAubioNameForPitchType(m_pitchtype)), - blockSize, - stepSize, - lrintf(m_inputSampleRate)); - - aubio_pitch_set_unit(m_pitchdet, const_cast("freq")); + reset(); return true; } @@ -114,6 +108,15 @@ void Pitch::reset() { + if (m_pitchdet) del_aubio_pitch(m_pitchdet); + + m_pitchdet = new_aubio_pitch + (const_cast(getAubioNameForPitchType(m_pitchtype)), + m_blockSize, + m_stepSize, + lrintf(m_inputSampleRate)); + + aubio_pitch_set_unit(m_pitchdet, const_cast("freq")); } size_t diff -r 5c5deb8393b9 -r 119e22552925 plugins/Tempo.cpp --- a/plugins/Tempo.cpp Tue Jul 10 17:29:42 2012 +0100 +++ b/plugins/Tempo.cpp Wed Jul 11 13:09:15 2012 +0100 @@ -94,16 +94,7 @@ m_delay = Vamp::RealTime::frame2RealTime(3 * stepSize, lrintf(m_inputSampleRate)); - m_lastBeat = Vamp::RealTime::zeroTime - m_delay - m_delay; - - m_tempo = new_aubio_tempo - (const_cast(getAubioNameForOnsetType(m_onsettype)), - blockSize, - stepSize, - lrintf(m_inputSampleRate)); - - aubio_tempo_set_silence(m_tempo, m_silence); - aubio_tempo_set_threshold(m_tempo, m_threshold); + reset(); return true; } @@ -111,6 +102,18 @@ 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(getAubioNameForOnsetType(m_onsettype)), + m_blockSize, + m_stepSize, + lrintf(m_inputSampleRate)); + + aubio_tempo_set_silence(m_tempo, m_silence); + aubio_tempo_set_threshold(m_tempo, m_threshold); } size_t