comparison src/Silvet.cpp @ 301:00fab71b80ec livemode

More tweaking of frequencies
author Chris Cannam
date Mon, 01 Dec 2014 17:12:19 +0000
parents ba5f3b084466
children cac0be04c43c
comparison
equal deleted inserted replaced
300:ba5f3b084466 301:00fab71b80ec
349 if (shiftCount > 1) { 349 if (shiftCount > 1) {
350 pshift = 350 pshift =
351 float((shiftCount - shift) - int(shiftCount / 2) - 1) / shiftCount; 351 float((shiftCount - shift) - int(shiftCount / 2) - 1) / shiftCount;
352 } 352 }
353 353
354 return float(27.5 * pow(2.0, (note + pshift) / 12.0)); 354 float freq = float(27.5 * pow(2.0, (note + pshift) / 12.0));
355
356 cerr << "note = " << note << ", shift = " << shift << ", shiftCount = "
357 << shiftCount << ", obtained freq = " << freq << endl;
358
359 return freq;
355 } 360 }
356 361
357 bool 362 bool
358 Silvet::initialise(size_t channels, size_t stepSize, size_t blockSize) 363 Silvet::initialise(size_t channels, size_t stepSize, size_t blockSize)
359 { 364 {
400 } 405 }
401 406
402 m_flattener = new FlattenDynamics(m_inputSampleRate); // before resampling 407 m_flattener = new FlattenDynamics(m_inputSampleRate); // before resampling
403 m_flattener->reset(); 408 m_flattener->reset();
404 409
410 // this happens to be processingSampleRate / 3, and is the top
411 // freq used for the EM templates:
412 double maxFreq = 14700;
413
414 if (m_mode == LiveMode) {
415 // We only have 12 bpo rather than 60, so we need the top bin
416 // to be the middle one of the top 5, i.e. 2/5 of a semitone
417 // lower than 14700
418 maxFreq *= powf(2.0, -1.0 / 30.0);
419 }
420
405 double minFreq = 27.5; 421 double minFreq = 27.5;
406 422
407 if (m_mode != HighQualityMode) { 423 if (m_mode != HighQualityMode) {
408 // We don't actually return any notes from the bottom octave, 424 // We don't actually return any notes from the bottom octave,
409 // so we can just pad with zeros 425 // so we can just pad with zeros
410 minFreq *= 2; 426 minFreq *= 2;
411 } 427 }
412 428
413 int bpo = 12 * 429 int bpo = 12 *
414 (m_mode == LiveMode ? binsPerSemitoneLive : binsPerSemitoneNormal); 430 (m_mode == LiveMode ? binsPerSemitoneLive : binsPerSemitoneNormal);
415 431
416 CQParameters params(processingSampleRate, 432 CQParameters params(processingSampleRate,
417 minFreq, 433 minFreq,
418 processingSampleRate / 3, 434 processingSampleRate / 3,
419 bpo); 435 bpo);
420 436
427 params.threshold = 0.0005; 443 params.threshold = 0.0005;
428 params.window = CQParameters::Hann; 444 params.window = CQParameters::Hann;
429 445
430 m_cq = new CQSpectrogram(params, CQSpectrogram::InterpolateLinear); 446 m_cq = new CQSpectrogram(params, CQSpectrogram::InterpolateLinear);
431 447
432 cerr << "cq latency = " << m_cq->getLatency() << endl; 448 cerr << "CQ bins = " << m_cq->getTotalBins() << endl;
449 cerr << "CQ min freq = " << m_cq->getMinFrequency() << " (and for confirmation, freq of bin 0 = " << m_cq->getBinFrequency(0) << ")" << endl;
433 450
434 m_colsPerSec = (m_mode == DraftMode ? 25 : 50); 451 m_colsPerSec = (m_mode == DraftMode ? 25 : 50);
435 452
436 for (int i = 0; i < (int)m_postFilter.size(); ++i) { 453 for (int i = 0; i < (int)m_postFilter.size(); ++i) {
437 delete m_postFilter[i]; 454 delete m_postFilter[i];