Mercurial > hg > vamp-simple-cepstrum
comparison SimpleCepstrum.cpp @ 43:fcb6562b43f7
Docs and fixes from plugin tester reports
author | Chris Cannam |
---|---|
date | Fri, 28 Nov 2014 15:28:07 +0000 |
parents | d6acf12f0a8e |
children | f021dc97da29 |
comparison
equal
deleted
inserted
replaced
42:745627478cf9 | 43:fcb6562b43f7 |
---|---|
142 | 142 |
143 ParameterDescriptor d; | 143 ParameterDescriptor d; |
144 | 144 |
145 d.identifier = "fmin"; | 145 d.identifier = "fmin"; |
146 d.name = "Minimum frequency"; | 146 d.name = "Minimum frequency"; |
147 d.description = ""; | 147 d.description = "Frequency whose period corresponds to the quefrency of the last cepstrum bin in range"; |
148 d.unit = "Hz"; | 148 d.unit = "Hz"; |
149 d.minValue = m_inputSampleRate / m_blockSize; | 149 d.minValue = m_inputSampleRate / m_blockSize; |
150 d.maxValue = m_inputSampleRate / 2; | 150 d.maxValue = m_inputSampleRate / 2; |
151 d.defaultValue = 50; | 151 d.defaultValue = 50; |
152 d.isQuantized = false; | 152 d.isQuantized = false; |
153 list.push_back(d); | 153 list.push_back(d); |
154 | 154 |
155 d.identifier = "fmax"; | 155 d.identifier = "fmax"; |
156 d.name = "Maximum frequency"; | 156 d.name = "Maximum frequency"; |
157 d.description = ""; | 157 d.description = "Frequency whose period corresponds to the quefrency of the first cepstrum bin in range"; |
158 d.unit = "Hz"; | 158 d.unit = "Hz"; |
159 d.minValue = m_inputSampleRate / m_blockSize; | 159 d.minValue = m_inputSampleRate / m_blockSize; |
160 d.maxValue = m_inputSampleRate / 2; | 160 d.maxValue = m_inputSampleRate / 2; |
161 d.defaultValue = 1000; | 161 d.defaultValue = 1000; |
162 d.isQuantized = false; | 162 d.isQuantized = false; |
163 list.push_back(d); | 163 list.push_back(d); |
164 | 164 |
165 d.identifier = "histlen"; | 165 d.identifier = "histlen"; |
166 d.name = "Mean filter history length"; | 166 d.name = "Mean filter history length"; |
167 d.description = ""; | 167 d.description = "Length of mean filter used for smoothing cepstrum across time bins"; |
168 d.unit = ""; | 168 d.unit = ""; |
169 d.minValue = 1; | 169 d.minValue = 1; |
170 d.maxValue = 10; | 170 d.maxValue = 10; |
171 d.defaultValue = 1; | 171 d.defaultValue = 1; |
172 d.isQuantized = true; | 172 d.isQuantized = true; |
173 d.quantizeStep = 1; | 173 d.quantizeStep = 1; |
174 list.push_back(d); | 174 list.push_back(d); |
175 | 175 |
176 d.identifier = "vflen"; | 176 d.identifier = "vflen"; |
177 d.name = "Vertical filter length"; | 177 d.name = "Vertical filter length"; |
178 d.description = ""; | 178 d.description = "Length of mean filter used for smoothing cepstrum across quefrency bins"; |
179 d.unit = ""; | 179 d.unit = ""; |
180 d.minValue = 1; | 180 d.minValue = 1; |
181 d.maxValue = 11; | 181 d.maxValue = 11; |
182 d.defaultValue = 1; | 182 d.defaultValue = 1; |
183 d.isQuantized = true; | 183 d.isQuantized = true; |
184 d.quantizeStep = 2; | 184 d.quantizeStep = 2; |
185 list.push_back(d); | 185 list.push_back(d); |
186 | 186 |
187 d.identifier = "method"; | 187 d.identifier = "method"; |
188 d.name = "Cepstrum transform method"; | 188 d.name = "Cepstrum transform method"; |
189 d.unit = ""; | 189 d.unit = "Method to use for calculating cepstrum, starting from the complex short-time Fourier transform of the input audio.\nInverse symmetric - Real part of inverse FFT of log magnitude spectrum, with frequencies above Nyquist reflecting those below it.\nInverse asymmetric - Real part of inverse FFT of log magnitude spectrum, with frequencies above Nyquist set to zero.\nInverse complex - Real part of inverse FFT of complex log spectrum.\nForward magnitude - Magnitude of forward FFT of log magnitude spectrum.\nForward difference - Difference between imaginary and real parts of forward FFT of log magnitude spectrum"; |
190 d.minValue = 0; | 190 d.minValue = 0; |
191 d.maxValue = 4; | 191 d.maxValue = 4; |
192 d.defaultValue = 0; | 192 d.defaultValue = 0; |
193 d.isQuantized = true; | 193 d.isQuantized = true; |
194 d.quantizeStep = 1; | 194 d.quantizeStep = 1; |
199 d.valueNames.push_back("Forward difference"); | 199 d.valueNames.push_back("Forward difference"); |
200 list.push_back(d); | 200 list.push_back(d); |
201 | 201 |
202 d.identifier = "clamp"; | 202 d.identifier = "clamp"; |
203 d.name = "Clamp negative values in cepstrum at zero"; | 203 d.name = "Clamp negative values in cepstrum at zero"; |
204 d.unit = ""; | 204 d.unit = "If set, no negative values will be returned; they will be replaced by zeroes"; |
205 d.minValue = 0; | 205 d.minValue = 0; |
206 d.maxValue = 1; | 206 d.maxValue = 1; |
207 d.defaultValue = 0; | 207 d.defaultValue = 0; |
208 d.isQuantized = true; | 208 d.isQuantized = true; |
209 d.quantizeStep = 1; | 209 d.quantizeStep = 1; |
332 d.unit = ""; | 332 d.unit = ""; |
333 d.description = "The unprocessed cepstrum bins within the specified range"; | 333 d.description = "The unprocessed cepstrum bins within the specified range"; |
334 | 334 |
335 int from = int(m_inputSampleRate / m_fmax); | 335 int from = int(m_inputSampleRate / m_fmax); |
336 int to = int(m_inputSampleRate / m_fmin); | 336 int to = int(m_inputSampleRate / m_fmin); |
337 if (from >= (int)m_blockSize / 2) { | |
338 from = m_blockSize / 2 - 1; | |
339 } | |
337 if (to >= (int)m_blockSize / 2) { | 340 if (to >= (int)m_blockSize / 2) { |
338 to = m_blockSize / 2 - 1; | 341 to = m_blockSize / 2 - 1; |
342 } | |
343 if (to < from) { | |
344 to = from; | |
339 } | 345 } |
340 d.binCount = to - from + 1; | 346 d.binCount = to - from + 1; |
341 for (int i = from; i <= to; ++i) { | 347 for (int i = from; i <= to; ++i) { |
342 float freq = m_inputSampleRate / i; | 348 float freq = m_inputSampleRate / i; |
343 char buffer[20]; | 349 char buffer[50]; |
344 sprintf(buffer, "%.2f Hz", freq); | 350 sprintf(buffer, "%.2f Hz", freq); |
345 d.binNames.push_back(buffer); | 351 d.binNames.push_back(buffer); |
346 } | 352 } |
347 | 353 |
348 d.hasKnownExtents = false; | 354 d.hasKnownExtents = false; |
360 d.description = "Envelope calculated from the cepstral values below the specified minimum"; | 366 d.description = "Envelope calculated from the cepstral values below the specified minimum"; |
361 d.binCount = m_blockSize/2 + 1; | 367 d.binCount = m_blockSize/2 + 1; |
362 d.binNames.clear(); | 368 d.binNames.clear(); |
363 for (int i = 0; i < (int)d.binCount; ++i) { | 369 for (int i = 0; i < (int)d.binCount; ++i) { |
364 float freq = (m_inputSampleRate / m_blockSize) * i; | 370 float freq = (m_inputSampleRate / m_blockSize) * i; |
365 char buffer[20]; | 371 char buffer[50]; |
366 sprintf(buffer, "%.2f Hz", freq); | 372 sprintf(buffer, "%.2f Hz", freq); |
367 d.binNames.push_back(buffer); | 373 d.binNames.push_back(buffer); |
368 } | 374 } |
369 m_envOutput = n++; | 375 m_envOutput = n++; |
370 outputs.push_back(d); | 376 outputs.push_back(d); |
391 m_channels = channels; | 397 m_channels = channels; |
392 m_stepSize = stepSize; | 398 m_stepSize = stepSize; |
393 m_blockSize = blockSize; | 399 m_blockSize = blockSize; |
394 | 400 |
395 m_binFrom = int(m_inputSampleRate / m_fmax); | 401 m_binFrom = int(m_inputSampleRate / m_fmax); |
396 m_binTo = int(m_inputSampleRate / m_fmin); | 402 m_binTo = int(m_inputSampleRate / m_fmin); |
397 | 403 |
404 if (m_binFrom >= (int)m_blockSize / 2) { | |
405 m_binFrom = m_blockSize / 2 - 1; | |
406 } | |
398 if (m_binTo >= (int)m_blockSize / 2) { | 407 if (m_binTo >= (int)m_blockSize / 2) { |
399 m_binTo = m_blockSize / 2 - 1; | 408 m_binTo = m_blockSize / 2 - 1; |
409 } | |
410 if (m_binTo < m_binFrom) { | |
411 m_binTo = m_binFrom; | |
400 } | 412 } |
401 | 413 |
402 m_bins = (m_binTo - m_binFrom) + 1; | 414 m_bins = (m_binTo - m_binFrom) + 1; |
403 | 415 |
404 m_history = new double *[m_histlen]; | 416 m_history = new double *[m_histlen]; |
615 } | 627 } |
616 for (int i = m_binFrom; i < bs; ++i) { | 628 for (int i = m_binFrom; i < bs; ++i) { |
617 ecep[i] = 0; | 629 ecep[i] = 0; |
618 } | 630 } |
619 ecep[0] /= 2; | 631 ecep[0] /= 2; |
620 ecep[m_binFrom-1] /= 2; | 632 if (m_binFrom > 0) { |
633 ecep[m_binFrom-1] /= 2; | |
634 } | |
621 | 635 |
622 double *env = new double[bs]; | 636 double *env = new double[bs]; |
623 double *io = new double[bs]; | 637 double *io = new double[bs]; |
624 | 638 |
625 //!!! This is only right if the previous transform was an inverse one! | 639 //!!! This is only right if the previous transform was an inverse one! |