comparison data/model/FFTModel.cpp @ 1571:5fe24e4af12c spectrogramparam

A little faster as vector
author Chris Cannam
date Thu, 08 Nov 2018 12:56:03 +0000
parents c2c8e071e24f
children f04038819c26
comparison
equal deleted inserted replaced
1570:410819150cd3 1571:5fe24e4af12c
452 452
453 window.push_back(value); 453 window.push_back(value);
454 454
455 // so-called median will actually be the dist*100'th percentile 455 // so-called median will actually be the dist*100'th percentile
456 medianWinSize = getPeakPickWindowSize(type, sampleRate, bin, dist); 456 medianWinSize = getPeakPickWindowSize(type, sampleRate, bin, dist);
457
457 halfWin = medianWinSize/2; 458 halfWin = medianWinSize/2;
458 459
459 while ((int)window.size() > medianWinSize) { 460 while ((int)window.size() > medianWinSize) {
460 window.pop_front(); 461 window.pop_front();
461 } 462 }
465 if (type == MajorPitchAdaptivePeaks) { 466 if (type == MajorPitchAdaptivePeaks) {
466 if (ymax + halfWin < nv) binmax = ymax + halfWin; 467 if (ymax + halfWin < nv) binmax = ymax + halfWin;
467 else binmax = nv - 1; 468 else binmax = nv - 1;
468 } 469 }
469 470
470 deque<float> sorted(window); 471 vector<float> sorted(window.begin(), window.end());
471 sort(sorted.begin(), sorted.end()); 472 sort(sorted.begin(), sorted.end());
472 float median = sorted[int(float(sorted.size()) * dist)]; 473 float median = sorted[int(float(sorted.size()) * dist)];
473 474
474 int centrebin = 0; 475 int centrebin = 0;
475 if (bin > actualSize/2) centrebin = bin - actualSize/2; 476 if (bin > actualSize/2) centrebin = bin - actualSize/2;