Mercurial > hg > svgui
changeset 1129:371320c9f8d9 spectrogram-minor-refactor
A threshold fix
author | Chris Cannam |
---|---|
date | Tue, 02 Aug 2016 09:09:58 +0100 |
parents | 4e022a3e567b |
children | dc4b8fd3fcb7 |
files | layer/ColourScale.cpp layer/SpectrogramLayer.cpp |
diffstat | 2 files changed, 21 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/ColourScale.cpp Mon Aug 01 16:25:06 2016 +0100 +++ b/layer/ColourScale.cpp Tue Aug 02 09:09:58 2016 +0100 @@ -19,6 +19,9 @@ #include "base/LogRange.h" #include <cmath> +#include <iostream> + +using namespace std; int ColourScale::m_maxPixel = 255; @@ -27,6 +30,8 @@ m_mapper(m_params.colourMap, 1.f, double(m_maxPixel)) { if (m_params.minValue >= m_params.maxValue) { + cerr << "ERROR: ColourScale::ColourScale: minValue = " + << m_params.minValue << ", maxValue = " << m_params.maxValue << endl; throw std::logic_error("maxValue must be greater than minValue"); } @@ -56,6 +61,12 @@ } if (m_mappedMin >= m_mappedMax) { + cerr << "ERROR: ColourScale::ColourScale: minValue = " << m_params.minValue + << ", maxValue = " << m_params.maxValue + << ", threshold = " << m_params.threshold + << ", scale = " << int(m_params.scale) + << " resulting in mapped minValue = " << m_mappedMin + << ", mapped maxValue = " << m_mappedMax << endl; throw std::logic_error("maxValue must be greater than minValue [after mapping]"); } }
--- a/layer/SpectrogramLayer.cpp Mon Aug 01 16:25:06 2016 +0100 +++ b/layer/SpectrogramLayer.cpp Tue Aug 02 09:09:58 2016 +0100 @@ -1456,15 +1456,21 @@ ColourScale::Parameters cparams; cparams.colourMap = m_colourMap; cparams.scale = m_colourScale; - cparams.threshold = m_threshold; - cparams.gain = m_gain; + + if (m_colourScale != ColourScaleType::Phase) { + cparams.gain = m_gain; + cparams.threshold = m_threshold; + } if (m_colourScale == ColourScaleType::Linear && m_normalization == ColumnNormalization::None) { //!!! This should not be necessary -- what is the actual range cparams.maxValue = 0.1; + if (cparams.maxValue <= m_threshold) { + cparams.maxValue = m_threshold + 0.1; + } } - + Colour3DPlotRenderer::Parameters params; params.colourScale = ColourScale(cparams); params.normalization = m_normalization; @@ -1475,8 +1481,7 @@ params.scaleFactor = 1.0; params.colourRotation = m_colourRotation; - if (m_colourScale != ColourScaleType::Phase && - m_normalization == ColumnNormalization::None) { + if (m_colourScale != ColourScaleType::Phase) { params.scaleFactor *= 2.f / float(getFFTSize()); } @@ -2103,9 +2108,7 @@ double dBval = dBmin + (((dBmax - dBmin) * i) / (ch - 1)); int idb = int(dBval); - //!!! double value = AudioLevel::dB_to_multiplier(dBval); - cerr << "dBval = " << dBval << ", value = " << value << endl; paint.setPen(getRenderer(v)->getColour(value)); int y = textHeight * topLines + 4 + ch - i;