Mercurial > hg > svgui
diff layer/ColourScale.cpp @ 1137:4e7ed3252d80 spectrogram-minor-refactor
Re-implement dB^2 (log-power) spectrogram setting
author | Chris Cannam |
---|---|
date | Thu, 04 Aug 2016 11:26:11 +0100 |
parents | 371320c9f8d9 |
children | 998e31e92dbe |
line wrap: on
line diff
--- a/layer/ColourScale.cpp Wed Aug 03 16:16:23 2016 +0100 +++ b/layer/ColourScale.cpp Thu Aug 04 11:26:11 2016 +0100 @@ -42,16 +42,16 @@ m_mappedMin = m_params.threshold; } - if (m_params.scale == ColourScaleType::Log) { + if (m_params.scaleType == ColourScaleType::Log) { LogRange::mapRange(m_mappedMin, m_mappedMax); - } else if (m_params.scale == ColourScaleType::PlusMinusOne) { + } else if (m_params.scaleType == ColourScaleType::PlusMinusOne) { m_mappedMin = -1.0; m_mappedMax = 1.0; - } else if (m_params.scale == ColourScaleType::Absolute) { + } else if (m_params.scaleType == ColourScaleType::Absolute) { m_mappedMin = fabs(m_mappedMin); m_mappedMax = fabs(m_mappedMax); @@ -64,7 +64,7 @@ cerr << "ERROR: ColourScale::ColourScale: minValue = " << m_params.minValue << ", maxValue = " << m_params.maxValue << ", threshold = " << m_params.threshold - << ", scale = " << int(m_params.scale) + << ", scale = " << int(m_params.scaleType) << " resulting in mapped minValue = " << m_mappedMin << ", mapped maxValue = " << m_mappedMax << endl; throw std::logic_error("maxValue must be greater than minValue [after mapping]"); @@ -78,7 +78,7 @@ ColourScaleType ColourScale::getScale() const { - return m_params.scale; + return m_params.scaleType; } int @@ -86,26 +86,30 @@ { double maxPixF = m_maxPixel; - if (m_params.scale == ColourScaleType::Phase) { + if (m_params.scaleType == ColourScaleType::Phase) { double half = (maxPixF - 1.f) / 2.f; return 1 + int((value * half) / M_PI + half); } value *= m_params.gain; +// value = pow(value, m_params.multiple); + if (value < m_params.threshold) return 0; double mapped = value; - if (m_params.scale == ColourScaleType::Log) { + if (m_params.scaleType == ColourScaleType::Log) { mapped = LogRange::map(value); - } else if (m_params.scale == ColourScaleType::PlusMinusOne) { + } else if (m_params.scaleType == ColourScaleType::PlusMinusOne) { if (mapped < -1.f) mapped = -1.f; if (mapped > 1.f) mapped = 1.f; - } else if (m_params.scale == ColourScaleType::Absolute) { + } else if (m_params.scaleType == ColourScaleType::Absolute) { if (mapped < 0.f) mapped = -mapped; } - + + mapped *= m_params.multiple; + if (mapped < m_mappedMin) { mapped = m_mappedMin; } @@ -117,7 +121,7 @@ int pixel = 0; - if (m_params.scale == ColourScaleType::Meter) { + if (m_params.scaleType == ColourScaleType::Meter) { pixel = AudioLevel::multiplier_to_preview(proportion, m_maxPixel-1) + 1; } else { pixel = int(proportion * maxPixF) + 1;