Mercurial > hg > silvet
comparison src/Silvet.cpp @ 303:d8468176339d livemode
More adjustments for live mode, including actually *using* the max frequency we calculated earlier
author | Chris Cannam |
---|---|
date | Fri, 05 Dec 2014 16:34:24 +0000 |
parents | cac0be04c43c |
children | f5f3b50b2b9f |
comparison
equal
deleted
inserted
replaced
302:cac0be04c43c | 303:d8468176339d |
---|---|
380 float((shiftCount - shift) - int(shiftCount / 2) - 1) / shiftCount; | 380 float((shiftCount - shift) - int(shiftCount / 2) - 1) / shiftCount; |
381 } | 381 } |
382 | 382 |
383 float freq = float(27.5 * pow(2.0, (note + pshift) / 12.0)); | 383 float freq = float(27.5 * pow(2.0, (note + pshift) / 12.0)); |
384 | 384 |
385 cerr << "note = " << note << ", shift = " << shift << ", shiftCount = " | 385 // cerr << "note = " << note << ", shift = " << shift << ", shiftCount = " |
386 << shiftCount << ", obtained freq = " << freq << endl; | 386 // << shiftCount << ", obtained freq = " << freq << endl; |
387 | 387 |
388 return freq; | 388 return freq; |
389 } | 389 } |
390 | 390 |
391 bool | 391 bool |
458 int bpo = 12 * | 458 int bpo = 12 * |
459 (m_mode == LiveMode ? binsPerSemitoneLive : binsPerSemitoneNormal); | 459 (m_mode == LiveMode ? binsPerSemitoneLive : binsPerSemitoneNormal); |
460 | 460 |
461 CQParameters params(processingSampleRate, | 461 CQParameters params(processingSampleRate, |
462 minFreq, | 462 minFreq, |
463 processingSampleRate / 3, | 463 maxFreq, |
464 bpo); | 464 bpo); |
465 | 465 |
466 params.q = 0.95; // MIREX code uses 0.8, but it seems 0.9 or lower | 466 params.q = 0.95; // MIREX code uses 0.8, but it seems 0.9 or lower |
467 // drops the FFT size to 512 from 1024 and alters | 467 // drops the FFT size to 512 from 1024 and alters |
468 // some other processing parameters, making | 468 // some other processing parameters, making |
472 params.threshold = 0.0005; | 472 params.threshold = 0.0005; |
473 params.window = CQParameters::Hann; | 473 params.window = CQParameters::Hann; |
474 | 474 |
475 m_cq = new CQSpectrogram(params, CQSpectrogram::InterpolateLinear); | 475 m_cq = new CQSpectrogram(params, CQSpectrogram::InterpolateLinear); |
476 | 476 |
477 cerr << "CQ bins = " << m_cq->getTotalBins() << endl; | 477 // cerr << "CQ bins = " << m_cq->getTotalBins() << endl; |
478 cerr << "CQ min freq = " << m_cq->getMinFrequency() << " (and for confirmation, freq of bin 0 = " << m_cq->getBinFrequency(0) << ")" << endl; | 478 // cerr << "CQ min freq = " << m_cq->getMinFrequency() << " (and for confirmation, freq of bin 0 = " << m_cq->getBinFrequency(0) << ")" << endl; |
479 | 479 |
480 m_colsPerSec = (m_mode == DraftMode ? 25 : 50); | 480 m_colsPerSec = (m_mode == DraftMode ? 25 : 50); |
481 | 481 |
482 for (int i = 0; i < (int)m_postFilter.size(); ++i) { | 482 for (int i = 0; i < (int)m_postFilter.size(); ++i) { |
483 delete m_postFilter[i]; | 483 delete m_postFilter[i]; |
484 } | 484 } |
485 m_postFilter.clear(); | 485 m_postFilter.clear(); |
486 int postFilterLength = 3; | |
486 for (int i = 0; i < getPack(0).templateNoteCount; ++i) { | 487 for (int i = 0; i < getPack(0).templateNoteCount; ++i) { |
487 m_postFilter.push_back(new MedianFilter<double>(3)); | 488 m_postFilter.push_back(new MedianFilter<double>(postFilterLength)); |
488 } | 489 } |
489 m_pianoRoll.clear(); | 490 m_pianoRoll.clear(); |
490 m_inputGains.clear(); | 491 m_inputGains.clear(); |
491 m_columnCount = 0; | 492 m_columnCount = 0; |
492 m_resampledCount = 0; | 493 m_resampledCount = 0; |
929 partShift = shift; | 930 partShift = shift; |
930 partVelocity = 0; | 931 partVelocity = 0; |
931 } | 932 } |
932 } | 933 } |
933 | 934 |
934 int v = round(strength * 2); | 935 int v; |
936 if (m_mode == LiveMode) { | |
937 v = round(strength * 30); | |
938 } else { | |
939 v = round(strength * 2); | |
940 } | |
935 if (v > partVelocity) { | 941 if (v > partVelocity) { |
936 partVelocity = v; | 942 partVelocity = v; |
937 } | 943 } |
938 } | 944 } |
939 | 945 |