Mercurial > hg > vamp-aubio-plugins
comparison plugins/Notes.cpp @ 37:119e22552925
Implement reset functions (fixes #498)
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Wed, 11 Jul 2012 13:09:15 +0100 |
parents | 5c5deb8393b9 |
children | b80056ac0503 |
comparison
equal
deleted
inserted
replaced
36:5c5deb8393b9 | 37:119e22552925 |
---|---|
103 | 103 |
104 m_ibuf = new_fvec(stepSize); | 104 m_ibuf = new_fvec(stepSize); |
105 m_onset = new_fvec(1); | 105 m_onset = new_fvec(1); |
106 m_pitch = new_fvec(1); | 106 m_pitch = new_fvec(1); |
107 | 107 |
108 reset(); | |
109 | |
110 return true; | |
111 } | |
112 | |
113 void | |
114 Notes::reset() | |
115 { | |
116 if (m_onsetdet) del_aubio_onset(m_onsetdet); | |
117 if (m_pitchdet) del_aubio_pitch(m_pitchdet); | |
118 | |
108 m_onsetdet = new_aubio_onset | 119 m_onsetdet = new_aubio_onset |
109 (const_cast<char *>(getAubioNameForOnsetType(m_onsettype)), | 120 (const_cast<char *>(getAubioNameForOnsetType(m_onsettype)), |
110 blockSize, | 121 m_blockSize, |
111 stepSize, | 122 m_stepSize, |
112 lrintf(m_inputSampleRate)); | 123 lrintf(m_inputSampleRate)); |
113 | 124 |
114 aubio_onset_set_threshold(m_onsetdet, m_threshold); | 125 aubio_onset_set_threshold(m_onsetdet, m_threshold); |
115 aubio_onset_set_silence(m_onsetdet, m_silence); | 126 aubio_onset_set_silence(m_onsetdet, m_silence); |
116 aubio_onset_set_minioi(m_onsetdet, m_minioi); | 127 aubio_onset_set_minioi(m_onsetdet, m_minioi); |
117 | 128 |
118 m_pitchdet = new_aubio_pitch | 129 m_pitchdet = new_aubio_pitch |
119 (const_cast<char *>(getAubioNameForPitchType(m_pitchtype)), | 130 (const_cast<char *>(getAubioNameForPitchType(m_pitchtype)), |
120 blockSize, | 131 m_blockSize, |
121 stepSize, | 132 m_stepSize, |
122 lrintf(m_inputSampleRate)); | 133 lrintf(m_inputSampleRate)); |
123 | 134 |
124 aubio_pitch_set_unit(m_pitchdet, const_cast<char *>("freq")); | 135 aubio_pitch_set_unit(m_pitchdet, const_cast<char *>("freq")); |
125 | 136 |
126 m_count = 0; | 137 m_count = 0; |
127 m_delay = Vamp::RealTime::frame2RealTime((4 + m_median) * m_stepSize, | 138 m_delay = Vamp::RealTime::frame2RealTime((4 + m_median) * m_stepSize, |
128 lrintf(m_inputSampleRate)); | 139 lrintf(m_inputSampleRate)); |
129 m_currentOnset = Vamp::RealTime::zeroTime; | 140 m_currentOnset = Vamp::RealTime::zeroTime; |
130 m_haveCurrent = false; | 141 m_haveCurrent = false; |
131 m_prevPitch = -1; | 142 m_prevPitch = -1; |
132 | |
133 return true; | |
134 } | |
135 | |
136 void | |
137 Notes::reset() | |
138 { | |
139 } | 143 } |
140 | 144 |
141 size_t | 145 size_t |
142 Notes::getPreferredStepSize() const | 146 Notes::getPreferredStepSize() const |
143 { | 147 { |