Mercurial > hg > svgui
comparison layer/SpectrumLayer.cpp @ 805:1d526ba11a24 warnfix_no_size_t
Remove size_t's and fix warnings in layer/
author | Chris Cannam |
---|---|
date | Tue, 17 Jun 2014 15:18:06 +0100 |
parents | 1a0dfcbffaf1 |
children | 4a578a360011 |
comparison
equal
deleted
inserted
replaced
782:ddae586bc47b | 805:1d526ba11a24 |
---|---|
119 StorageAdviser::FrequentLookupLikely)); | 119 StorageAdviser::FrequentLookupLikely)); |
120 | 120 |
121 setSliceableModel(newFFT); | 121 setSliceableModel(newFFT); |
122 | 122 |
123 m_biasCurve.clear(); | 123 m_biasCurve.clear(); |
124 for (size_t i = 0; i < m_windowSize; ++i) { | 124 for (int i = 0; i < m_windowSize; ++i) { |
125 m_biasCurve.push_back(1.f / (float(m_windowSize)/2.f)); | 125 m_biasCurve.push_back(1.f / (float(m_windowSize)/2.f)); |
126 } | 126 } |
127 | 127 |
128 newFFT->resume(); | 128 newFFT->resume(); |
129 | 129 |
255 SliceLayer::setProperty(name, value); | 255 SliceLayer::setProperty(name, value); |
256 } | 256 } |
257 } | 257 } |
258 | 258 |
259 void | 259 void |
260 SpectrumLayer::setWindowSize(size_t ws) | 260 SpectrumLayer::setWindowSize(int ws) |
261 { | 261 { |
262 if (m_windowSize == ws) return; | 262 if (m_windowSize == ws) return; |
263 m_windowSize = ws; | 263 m_windowSize = ws; |
264 m_newFFTNeeded = true; | 264 m_newFFTNeeded = true; |
265 emit layerParametersChanged(); | 265 emit layerParametersChanged(); |
266 } | 266 } |
267 | 267 |
268 void | 268 void |
269 SpectrumLayer::setWindowHopLevel(size_t v) | 269 SpectrumLayer::setWindowHopLevel(int v) |
270 { | 270 { |
271 if (m_windowHopLevel == v) return; | 271 if (m_windowHopLevel == v) return; |
272 m_windowHopLevel = v; | 272 m_windowHopLevel = v; |
273 m_newFFTNeeded = true; | 273 m_newFFTNeeded = true; |
274 emit layerParametersChanged(); | 274 emit layerParametersChanged(); |
564 SpectrumLayer::getFeatureDescription(View *v, QPoint &p) const | 564 SpectrumLayer::getFeatureDescription(View *v, QPoint &p) const |
565 { | 565 { |
566 if (!m_sliceableModel) return ""; | 566 if (!m_sliceableModel) return ""; |
567 | 567 |
568 int minbin = 0, maxbin = 0, range = 0; | 568 int minbin = 0, maxbin = 0, range = 0; |
569 QString genericDesc = SliceLayer::getFeatureDescription | 569 QString genericDesc = SliceLayer::getFeatureDescriptionAux |
570 (v, p, false, minbin, maxbin, range); | 570 (v, p, false, minbin, maxbin, range); |
571 | 571 |
572 if (genericDesc == "") return ""; | 572 if (genericDesc == "") return ""; |
573 | 573 |
574 float minvalue = 0.f; | 574 float minvalue = 0.f; |
682 | 682 |
683 // draw peak lines | 683 // draw peak lines |
684 | 684 |
685 // SVDEBUG << "Showing peaks..." << endl; | 685 // SVDEBUG << "Showing peaks..." << endl; |
686 | 686 |
687 size_t col = v->getCentreFrame() / fft->getResolution(); | 687 int col = v->getCentreFrame() / fft->getResolution(); |
688 | 688 |
689 paint.save(); | 689 paint.save(); |
690 paint.setRenderHint(QPainter::Antialiasing, false); | 690 paint.setRenderHint(QPainter::Antialiasing, false); |
691 paint.setPen(QColor(160, 160, 160)); //!!! | 691 paint.setPen(QColor(160, 160, 160)); //!!! |
692 | 692 |
700 | 700 |
701 ColourMapper mapper(ColourMapper::BlackOnWhite, 0, 1); | 701 ColourMapper mapper(ColourMapper::BlackOnWhite, 0, 1); |
702 | 702 |
703 BiasCurve curve; | 703 BiasCurve curve; |
704 getBiasCurve(curve); | 704 getBiasCurve(curve); |
705 size_t cs = curve.size(); | 705 int cs = curve.size(); |
706 | 706 |
707 std::vector<float> values; | 707 std::vector<float> values; |
708 | 708 |
709 for (size_t bin = 0; bin < fft->getHeight(); ++bin) { | 709 for (int bin = 0; bin < fft->getHeight(); ++bin) { |
710 float value = m_sliceableModel->getValueAt(col, bin); | 710 float value = m_sliceableModel->getValueAt(col, bin); |
711 if (bin < cs) value *= curve[bin]; | 711 if (bin < cs) value *= curve[bin]; |
712 values.push_back(value); | 712 values.push_back(value); |
713 } | 713 } |
714 | 714 |
715 for (FFTModel::PeakSet::iterator i = peaks.begin(); | 715 for (FFTModel::PeakSet::iterator i = peaks.begin(); |
716 i != peaks.end(); ++i) { | 716 i != peaks.end(); ++i) { |
717 | 717 |
718 size_t bin = i->first; | 718 int bin = i->first; |
719 | 719 |
720 // cerr << "bin = " << bin << ", thresh = " << thresh << ", value = " << fft->getMagnitudeAt(col, bin) << endl; | 720 // cerr << "bin = " << bin << ", thresh = " << thresh << ", value = " << fft->getMagnitudeAt(col, bin) << endl; |
721 | 721 |
722 if (!fft->isOverThreshold(col, bin, thresh)) continue; | 722 if (!fft->isOverThreshold(col, bin, thresh)) continue; |
723 | 723 |
724 float freq = i->second; | 724 float freq = i->second; |
725 | 725 |
726 int x = lrintf(getXForFrequency(freq, w)); | 726 int x = lrintf(getXForFrequency(freq, w)); |
727 | 727 |
728 float norm = 0.f; | 728 float norm = 0.f; |
729 float y = getYForValue(values[bin], v, norm); // don't need y, need norm | 729 (void)getYForValue(values[bin], v, norm); // don't need return value, need norm |
730 | 730 |
731 paint.setPen(mapper.map(norm)); | 731 paint.setPen(mapper.map(norm)); |
732 paint.drawLine(xorigin + x, 0, xorigin + x, v->height() - pkh - 1); | 732 paint.drawLine(xorigin + x, 0, xorigin + x, v->height() - pkh - 1); |
733 } | 733 } |
734 | 734 |
848 { | 848 { |
849 SliceLayer::setProperties(attributes); | 849 SliceLayer::setProperties(attributes); |
850 | 850 |
851 bool ok = false; | 851 bool ok = false; |
852 | 852 |
853 size_t windowSize = attributes.value("windowSize").toUInt(&ok); | 853 int windowSize = attributes.value("windowSize").toUInt(&ok); |
854 if (ok) setWindowSize(windowSize); | 854 if (ok) setWindowSize(windowSize); |
855 | 855 |
856 size_t windowHopLevel = attributes.value("windowHopLevel").toUInt(&ok); | 856 int windowHopLevel = attributes.value("windowHopLevel").toUInt(&ok); |
857 if (ok) setWindowHopLevel(windowHopLevel); | 857 if (ok) setWindowHopLevel(windowHopLevel); |
858 | 858 |
859 bool showPeaks = (attributes.value("showPeaks").trimmed() == "true"); | 859 bool showPeaks = (attributes.value("showPeaks").trimmed() == "true"); |
860 setShowPeaks(showPeaks); | 860 setShowPeaks(showPeaks); |
861 } | 861 } |