Mercurial > hg > constant-q-cpp
comparison vamp/CQChromaVamp.cpp @ 147:1060a19e2334
Report validity of CQKernel construction, and avoid NaN values for invalid parameters. Also documentation.
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Thu, 10 Jul 2014 12:19:39 +0100 |
parents | 1e33f719dde1 |
children | 242bf7bc38ce |
comparison
equal
deleted
inserted
replaced
146:0cbd9c904dbb | 147:1060a19e2334 |
---|---|
221 | 221 |
222 // Min frequency is frequency of midiPitchLimit lowered by the | 222 // Min frequency is frequency of midiPitchLimit lowered by the |
223 // appropriate number of octaves. | 223 // appropriate number of octaves. |
224 m_minFrequency = midiPitchLimitFreq / pow(2, m_octaveCount + 1); | 224 m_minFrequency = midiPitchLimitFreq / pow(2, m_octaveCount + 1); |
225 | 225 |
226 cerr << "lowest octave: " << m_lowestOctave << ", highest octave: " | 226 // cerr << "lowest octave: " << m_lowestOctave << ", highest octave: " |
227 << highestOctave << ", limit midi pitch: " << midiPitchLimit | 227 // << highestOctave << ", limit midi pitch: " << midiPitchLimit |
228 << ", min freq " << m_minFrequency << ", max freq " << m_maxFrequency | 228 // << ", min freq " << m_minFrequency << ", max freq " << m_maxFrequency |
229 << endl; | 229 // << endl; |
230 | 230 |
231 reset(); | |
232 | |
233 if (!m_cq || !m_cq->isValid()) { | |
234 cerr << "CQVamp::initialise: Constant-Q parameters not valid! Not initialising" << endl; | |
235 return false; | |
236 } | |
237 | |
238 return true; | |
239 } | |
240 | |
241 void | |
242 CQChromaVamp::reset() | |
243 { | |
244 cerr << "reset: rate " << m_inputSampleRate << ", minf " << m_minFrequency << ", maxf " << m_maxFrequency << ", bpo " << m_bpo << endl; | |
245 | |
246 delete m_cq; | |
231 CQParameters p(m_inputSampleRate, m_minFrequency, m_maxFrequency, m_bpo); | 247 CQParameters p(m_inputSampleRate, m_minFrequency, m_maxFrequency, m_bpo); |
232 m_cq = new CQSpectrogram(p, CQSpectrogram::InterpolateLinear); | 248 m_cq = new CQSpectrogram(p, CQSpectrogram::InterpolateLinear); |
233 | 249 |
234 return true; | |
235 } | |
236 | |
237 void | |
238 CQChromaVamp::reset() | |
239 { | |
240 if (m_cq) { | |
241 delete m_cq; | |
242 CQParameters p(m_inputSampleRate, m_minFrequency, m_maxFrequency, m_bpo); | |
243 m_cq = new CQSpectrogram(p, CQSpectrogram::InterpolateLinear); | |
244 } | |
245 m_haveStartTime = false; | 250 m_haveStartTime = false; |
251 m_startTime = Vamp::RealTime::zeroTime; | |
246 m_columnCount = 0; | 252 m_columnCount = 0; |
247 } | 253 } |
248 | 254 |
249 size_t | 255 size_t |
250 CQChromaVamp::getPreferredStepSize() const | 256 CQChromaVamp::getPreferredStepSize() const |
342 vector<float> column(m_bpo, 0.f); | 348 vector<float> column(m_bpo, 0.f); |
343 | 349 |
344 // fold and invert to put low frequencies at the start | 350 // fold and invert to put low frequencies at the start |
345 | 351 |
346 int thisHeight = cqout[i].size(); | 352 int thisHeight = cqout[i].size(); |
353 | |
347 for (int j = 0; j < thisHeight; ++j) { | 354 for (int j = 0; j < thisHeight; ++j) { |
348 column[m_bpo - (j % m_bpo) - 1] += cqout[i][j]; | 355 column[m_bpo - (j % m_bpo) - 1] += cqout[i][j]; |
349 } | 356 } |
350 | 357 |
351 Feature feature; | 358 Feature feature; |