# HG changeset patch # User Chris Cannam # Date 1542210441 0 # Node ID ba1f0234efa73f4eebc6a6936683eaec9f11ff74 # Parent f228bee4981c31f2d1f90c02d9f2788167675550 Fixes to spectrum axis calculations, + default to starting at bin 1 diff -r f228bee4981c -r ba1f0234efa7 layer/SliceLayer.cpp --- a/layer/SliceLayer.cpp Wed Nov 14 15:14:21 2018 +0000 +++ b/layer/SliceLayer.cpp Wed Nov 14 15:47:21 2018 +0000 @@ -209,9 +209,13 @@ int w = pw - origin; if (w < 1) w = 1; + if (pmax <= pmin) { + pmax = pmin + 1.0; + } + if (p < pmin) p = pmin; if (p > pmax) p = pmax; - + if (m_binScale == LinearBins) { x = (w * (p - pmin)) / (pmax - pmin); } else { @@ -246,16 +250,14 @@ double pmaxlog = log10(pmax + reqdshift + origin); double plog = log10(p + reqdshift + origin); x = (w * (plog - pminlog)) / (pmaxlog - pminlog); - -/* + /* cerr << "getXForScalePoint(" << p << "): pmin = " << pmin << ", pmax = " << pmax << ", w = " << w << ", reqdshift = " << reqdshift << ", pminlog = " << pminlog << ", pmaxlog = " << pmaxlog << ", plog = " << plog << " -> x = " << x << endl; -*/ - + */ if (m_binScale == InvertedLogBins) { // still stoopid x = w - x; @@ -288,6 +290,10 @@ double eps = 1e-10; + if (pmax <= pmin) { + pmax = pmin + 1.0; + } + if (m_binScale == LinearBins) { p = pmin + eps + (x * (pmax - pmin)) / w; } else { diff -r f228bee4981c -r ba1f0234efa7 layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Wed Nov 14 15:14:21 2018 +0000 +++ b/layer/SpectrogramLayer.cpp Wed Nov 14 15:47:21 2018 +0000 @@ -698,7 +698,6 @@ return; } if (name == "Spectrogram Y Smoothing") { - setWindowSize(m_windowSize); invalidateRenderers(); invalidateMagnitudes(); emit layerParametersChanged(); @@ -783,21 +782,6 @@ SpectrogramLayer::getOversampling() const { return m_oversampling; - /*!!! - if (m_binDisplay != BinDisplay::AllBins) { - return 1; - } - - Preferences::SpectrogramSmoothing smoothing = - Preferences::getInstance()->getSpectrogramSmoothing(); - - if (smoothing == Preferences::NoSpectrogramSmoothing || - smoothing == Preferences::SpectrogramInterpolated) { - return 1; - } - - return 4; - */ } void @@ -1556,8 +1540,7 @@ Preferences::SpectrogramSmoothing smoothing = Preferences::getInstance()->getSpectrogramSmoothing(); params.interpolate = - (smoothing == Preferences::SpectrogramInterpolated || - smoothing == Preferences::SpectrogramZeroPaddedAndInterpolated); + (smoothing != Preferences::NoSpectrogramSmoothing); m_renderers[viewId] = new Colour3DPlotRenderer(sources, params); diff -r f228bee4981c -r ba1f0234efa7 layer/SpectrumLayer.cpp --- a/layer/SpectrumLayer.cpp Wed Nov 14 15:14:21 2018 +0000 +++ b/layer/SpectrumLayer.cpp Wed Nov 14 15:47:21 2018 +0000 @@ -122,6 +122,11 @@ getWindowIncrement(), fftSize); + if (m_minbin == 0 && m_maxbin == 0) { + m_minbin = 1; + m_maxbin = newFFT->getHeight(); + } + setSliceableModel(newFFT); m_biasCurve.clear(); @@ -433,6 +438,7 @@ if (!m_sliceableModel) return 0; double fmin = getFrequencyForBin(m_minbin); + if (m_binScale == LogBins && m_minbin == 0) { // See comment in getFrequencyForX above fmin = getFrequencyForBin(0.8); @@ -440,8 +446,8 @@ } double fmax = getFrequencyForBin(m_maxbin); - double x = getXForScalePoint(v, freq, fmin, fmax); + return x; }