comparison data/model/FFTModel.cpp @ 1575:054bbf17ac17 spectrogramparam

Slightly simplify median-window size calculation - but this is not the best way to do this for spectrum views, need to reconsider
author Chris Cannam
date Mon, 12 Nov 2018 14:48:15 +0000
parents f04038819c26
children 0f62bce0f0be
comparison
equal deleted inserted replaced
1574:cfcfec216c21 1575:054bbf17ac17
387 387
388 FFTModel::PeakLocationSet 388 FFTModel::PeakLocationSet
389 FFTModel::getPeaks(PeakPickType type, int x, int ymin, int ymax) const 389 FFTModel::getPeaks(PeakPickType type, int x, int ymin, int ymax) const
390 { 390 {
391 Profiler profiler("FFTModel::getPeaks"); 391 Profiler profiler("FFTModel::getPeaks");
392 392
393 FFTModel::PeakLocationSet peaks; 393 FFTModel::PeakLocationSet peaks;
394 if (!isOK()) return peaks; 394 if (!isOK()) return peaks;
395 395
396 if (ymax == 0 || ymax > getHeight() - 1) { 396 if (ymax == 0 || ymax > getHeight() - 1) {
397 ymax = getHeight() - 1; 397 ymax = getHeight() - 1;
516 double binfreq = (sampleRate * bin) / m_fftSize; 516 double binfreq = (sampleRate * bin) / m_fftSize;
517 double hifreq = Pitch::getFrequencyForPitch(73, 0, binfreq); 517 double hifreq = Pitch::getFrequencyForPitch(73, 0, binfreq);
518 518
519 int hibin = int(lrint((hifreq * m_fftSize) / sampleRate)); 519 int hibin = int(lrint((hifreq * m_fftSize) / sampleRate));
520 int medianWinSize = hibin - bin; 520 int medianWinSize = hibin - bin;
521 if (medianWinSize < 3) medianWinSize = 3; 521 if (medianWinSize < 3) {
522 medianWinSize = 3;
523 }
524 if (medianWinSize > 20) {
525 medianWinSize = (1 + medianWinSize / 10) * 10;
526 }
527 if (medianWinSize > 500) {
528 medianWinSize = 500;
529 }
522 530
523 percentile = 0.5f + float(binfreq / sampleRate); 531 percentile = 0.5f + float(binfreq / sampleRate);
524 532 if (percentile > 0.9f) percentile = 0.9f;
533
525 return medianWinSize; 534 return medianWinSize;
526 } 535 }
527 536
528 FFTModel::PeakSet 537 FFTModel::PeakSet
529 FFTModel::getPeakFrequencies(PeakPickType type, int x, 538 FFTModel::getPeakFrequencies(PeakPickType type, int x,