comparison layer/SpectrumLayer.cpp @ 1385:37e9d6a1e00c spectrogramparam

Retrieve only the values already determined to be peaks
author Chris Cannam
date Thu, 08 Nov 2018 12:55:36 +0000
parents 2df1af7ac752
children fc3d89f88690
comparison
equal deleted inserted replaced
1384:413e09f303ba 1385:37e9d6a1e00c
677 677
678 BiasCurve curve; 678 BiasCurve curve;
679 getBiasCurve(curve); 679 getBiasCurve(curve);
680 int cs = int(curve.size()); 680 int cs = int(curve.size());
681 681
682 std::vector<double> values;
683
684 for (int bin = 0; bin < fft->getHeight(); ++bin) {
685 double value = m_sliceableModel->getValueAt(col, bin);
686 if (bin < cs) value *= curve[bin];
687 values.push_back(value);
688 }
689
690 for (FFTModel::PeakSet::iterator i = peaks.begin(); 682 for (FFTModel::PeakSet::iterator i = peaks.begin();
691 i != peaks.end(); ++i) { 683 i != peaks.end(); ++i) {
692 684
693 int bin = i->first; 685 int bin = i->first;
694 686
695 // cerr << "bin = " << bin << ", thresh = " << thresh << ", value = " << fft->getMagnitudeAt(col, bin) << endl; 687 // cerr << "bin = " << bin << ", thresh = " << thresh << ", value = " << fft->getMagnitudeAt(col, bin) << endl;
696 688
697 if (!fft->isOverThreshold(col, bin, float(thresh))) continue; 689 double value = fft->getValueAt(col, bin);
690 if (value < thresh) continue;
691 if (bin < cs) value *= curve[bin];
698 692
699 double freq = i->second; 693 double freq = i->second;
700
701 int x = int(lrint(getXForFrequency(v, freq))); 694 int x = int(lrint(getXForFrequency(v, freq)));
702 695
703 double norm = 0.f; 696 double norm = 0.f;
704 (void)getYForValue(v, values[bin], norm); // don't need return value, need norm 697 // don't need return value, need norm:
698 (void)getYForValue(v, value, norm);
705 699
706 paint.setPen(mapper.map(norm)); 700 paint.setPen(mapper.map(norm));
707 paint.drawLine(x, 0, x, v->getPaintHeight() - scaleHeight - 1); 701 paint.drawLine(x, 0, x, v->getPaintHeight() - scaleHeight - 1);
708 } 702 }
709 703