comparison layer/SpectrumLayer.cpp @ 1399:ba1f0234efa7

Fixes to spectrum axis calculations, + default to starting at bin 1
author Chris Cannam
date Wed, 14 Nov 2018 15:47:21 +0000
parents f228bee4981c
children decb7741d036
comparison
equal deleted inserted replaced
1398:f228bee4981c 1399:ba1f0234efa7
120 m_windowType, 120 m_windowType,
121 m_windowSize, 121 m_windowSize,
122 getWindowIncrement(), 122 getWindowIncrement(),
123 fftSize); 123 fftSize);
124 124
125 if (m_minbin == 0 && m_maxbin == 0) {
126 m_minbin = 1;
127 m_maxbin = newFFT->getHeight();
128 }
129
125 setSliceableModel(newFFT); 130 setSliceableModel(newFFT);
126 131
127 m_biasCurve.clear(); 132 m_biasCurve.clear();
128 for (int i = 0; i < fftSize; ++i) { 133 for (int i = 0; i < fftSize; ++i) {
129 m_biasCurve.push_back(1.f / (float(fftSize)/2.f)); 134 m_biasCurve.push_back(1.f / (float(fftSize)/2.f));
431 SpectrumLayer::getXForFrequency(const LayerGeometryProvider *v, double freq) const 436 SpectrumLayer::getXForFrequency(const LayerGeometryProvider *v, double freq) const
432 { 437 {
433 if (!m_sliceableModel) return 0; 438 if (!m_sliceableModel) return 0;
434 439
435 double fmin = getFrequencyForBin(m_minbin); 440 double fmin = getFrequencyForBin(m_minbin);
441
436 if (m_binScale == LogBins && m_minbin == 0) { 442 if (m_binScale == LogBins && m_minbin == 0) {
437 // See comment in getFrequencyForX above 443 // See comment in getFrequencyForX above
438 fmin = getFrequencyForBin(0.8); 444 fmin = getFrequencyForBin(0.8);
439 if (fmin > 6.0) fmin = 6.0; 445 if (fmin > 6.0) fmin = 6.0;
440 } 446 }
441 447
442 double fmax = getFrequencyForBin(m_maxbin); 448 double fmax = getFrequencyForBin(m_maxbin);
443
444 double x = getXForScalePoint(v, freq, fmin, fmax); 449 double x = getXForScalePoint(v, freq, fmin, fmax);
450
445 return x; 451 return x;
446 } 452 }
447 453
448 bool 454 bool
449 SpectrumLayer::getXScaleValue(const LayerGeometryProvider *v, int x, 455 SpectrumLayer::getXScaleValue(const LayerGeometryProvider *v, int x,