Mercurial > hg > svgui
changeset 1127:9fb8dfd7ce4c spectrogram-minor-refactor
Fix threshold in spectrogram -- it wasn't working in the last release.
There is a new protocol for this. Formerly the threshold parameter had a
range from -50dB to 0 with the default at -50, and -50 treated internally
as "no threshold". However, there was a hardcoded, hidden internal threshold
for spectrogram colour mapping at -80dB with anything below this being rounded
to zero. Now the threshold parameter has range -81 to -1 with the default
at -80, -81 is treated internally as "no threshold", and there is no hidden
internal threshold. So the default behaviour is the same as before, an
effective -80dB threshold, but it is now possible to change this in both
directions. Sessions reloaded from prior versions may look slightly different
because, if the session says there should be no threshold, there will now
actually be no threshold instead of having the hidden internal one.
Still need to do something in the UI to make it apparent that the -81dB
setting removes the threshold entirely. This is at least no worse than the
previous, also obscured, magic -50dB setting.
author | Chris Cannam |
---|---|
date | Mon, 01 Aug 2016 16:21:01 +0100 |
parents | 5c3333fb70b3 |
children | 4e022a3e567b |
files | layer/ColourScale.cpp layer/SpectrogramLayer.cpp layer/SpectrogramLayer.h |
diffstat | 3 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/ColourScale.cpp Mon Aug 01 16:13:29 2016 +0100 +++ b/layer/ColourScale.cpp Mon Aug 01 16:21:01 2016 +0100 @@ -33,6 +33,10 @@ m_mappedMin = m_params.minValue; m_mappedMax = m_params.maxValue; + if (m_mappedMin < m_params.threshold) { + m_mappedMin = m_params.threshold; + } + if (m_params.scale == ColourScaleType::Log) { LogRange::mapRange(m_mappedMin, m_mappedMax);
--- a/layer/SpectrogramLayer.cpp Mon Aug 01 16:13:29 2016 +0100 +++ b/layer/SpectrogramLayer.cpp Mon Aug 01 16:21:01 2016 +0100 @@ -65,8 +65,8 @@ m_windowHopLevel(2), m_gain(1.0), m_initialGain(1.0), - m_threshold(0.0), - m_initialThreshold(0.0), + m_threshold(1.0e-8), + m_initialThreshold(1.0e-8), m_colourRotation(0), m_initialRotation(0), m_minFrequency(10), @@ -304,8 +304,8 @@ } else if (name == "Threshold") { - *min = -50; - *max = 0; + *min = -81; + *max = -1; *deflt = int(lrint(AudioLevel::multiplier_to_dB(m_initialThreshold))); if (*deflt < *min) *deflt = *min; @@ -530,7 +530,7 @@ return new LinearRangeMapper(-50, 50, -25, 25, tr("dB")); } if (name == "Threshold") { - return new LinearRangeMapper(-50, 0, -50, 0, tr("dB")); + return new LinearRangeMapper(-81, -1, -81, -1, tr("dB")); } return 0; } @@ -541,7 +541,7 @@ if (name == "Gain") { setGain(float(pow(10, float(value)/20.0))); } else if (name == "Threshold") { - if (value == -50) setThreshold(0.0); + if (value == -81) setThreshold(0.0); else setThreshold(float(AudioLevel::dB_to_multiplier(value))); } else if (name == "Colour Rotation") { setColourRotation(value); @@ -2055,6 +2055,9 @@ double min = m_viewMags[v->getId()].getMin(); double max = m_viewMags[v->getId()].getMax(); + if (min < m_threshold) min = m_threshold; + if (max < min) max = min; + double dBmin = AudioLevel::multiplier_to_dB(min); double dBmax = AudioLevel::multiplier_to_dB(max);
--- a/layer/SpectrogramLayer.h Mon Aug 01 16:13:29 2016 +0100 +++ b/layer/SpectrogramLayer.h Mon Aug 01 16:21:01 2016 +0100 @@ -125,7 +125,7 @@ * Set the threshold for sample values to qualify for being shown * in the FFT, in voltage units. * - * The default is 0.0. + * The default is 10^-8 (-80dB). */ void setThreshold(float threshold); float getThreshold() const;