Mercurial > hg > svgui
comparison layer/SpectrumLayer.cpp @ 1391:c39f2d439d59 spectrogramparam
Toward highlighting peaks on spectrum
author | Chris Cannam |
---|---|
date | Tue, 13 Nov 2018 15:16:48 +0000 |
parents | 1eb560b363e7 |
children | 900bed394f5a |
comparison
equal
deleted
inserted
replaced
1390:3c99083a4d83 | 1391:c39f2d439d59 |
---|---|
707 double thresh = (pow(10, -6) / m_gain) * (getFFTSize() / 2.0); // -60dB adj | 707 double thresh = (pow(10, -6) / m_gain) * (getFFTSize() / 2.0); // -60dB adj |
708 | 708 |
709 int xorigin = getVerticalScaleWidth(v, false, paint) + 1; | 709 int xorigin = getVerticalScaleWidth(v, false, paint) + 1; |
710 int scaleHeight = getHorizontalScaleHeight(v, paint); | 710 int scaleHeight = getHorizontalScaleHeight(v, paint); |
711 | 711 |
712 QPoint localPos; | |
713 bool shouldIlluminate = v->shouldIlluminateLocalFeatures(this, localPos); | |
714 | |
715 cerr << "shouldIlluminate = " << shouldIlluminate << ", localPos = " << localPos.x() << "," << localPos.y() << endl; | |
716 | |
712 if (fft && m_showPeaks) { | 717 if (fft && m_showPeaks) { |
713 | 718 |
714 // draw peak lines | 719 // draw peak lines |
715 | 720 |
716 int col = int(v->getCentreFrame() / fft->getResolution()); | 721 int col = int(v->getCentreFrame() / fft->getResolution()); |
736 getBiasCurve(curve); | 741 getBiasCurve(curve); |
737 int cs = int(curve.size()); | 742 int cs = int(curve.size()); |
738 | 743 |
739 int px = -1; | 744 int px = -1; |
740 | 745 |
746 int fuzz = ViewManager::scalePixelSize(2); | |
747 | |
741 for (FFTModel::PeakSet::iterator i = peaks.begin(); | 748 for (FFTModel::PeakSet::iterator i = peaks.begin(); |
742 i != peaks.end(); ++i) { | 749 i != peaks.end(); ++i) { |
743 | 750 |
744 double freq = i->second; | 751 double freq = i->second; |
745 int x = int(lrint(getXForFrequency(v, freq))); | 752 int x = int(lrint(getXForFrequency(v, freq))); |
746 if (x == px) { | 753 if (x == px) { |
747 continue; | 754 continue; |
748 } | 755 } |
749 | 756 |
750 int bin = i->first; | 757 int bin = i->first; |
751 | 758 |
752 // cerr << "bin = " << bin << ", thresh = " << thresh << ", value = " << fft->getMagnitudeAt(col, bin) << endl; | 759 // cerr << "bin = " << bin << ", thresh = " << thresh << ", value = " << fft->getMagnitudeAt(col, bin) << endl; |
753 | 760 |
754 double value = fft->getValueAt(col, bin); | 761 double value = fft->getValueAt(col, bin); |
755 if (value < thresh) continue; | 762 if (value < thresh) continue; |
756 if (bin < cs) value *= curve[bin]; | 763 if (bin < cs) value *= curve[bin]; |
764 | |
765 bool highlightThis = false; | |
766 if (std::abs(localPos.x() - x) <= fuzz) { | |
767 highlightThis = true; | |
768 cerr << "should highlight this one (at " << x << ")" << endl; | |
769 } | |
757 | 770 |
758 double norm = 0.f; | 771 double norm = 0.f; |
759 // don't need return value, need norm: | 772 // don't need return value, need norm: |
760 (void)getYForValue(v, value, norm); | 773 (void)getYForValue(v, value, norm); |
761 | 774 |