diff layer/SpectrogramLayer.cpp @ 1125:50324fca1328 spectrogram-minor-refactor

Scale range matching
author Chris Cannam
date Mon, 01 Aug 2016 15:06:16 +0100
parents 343887ac6766
children 9fb8dfd7ce4c
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Mon Aug 01 11:31:53 2016 +0100
+++ b/layer/SpectrogramLayer.cpp	Mon Aug 01 15:06:16 2016 +0100
@@ -1459,9 +1459,10 @@
         cparams.threshold = m_threshold;
         cparams.gain = m_gain;
 
-        if (m_colourScale != ColourScaleType::Phase &&
+        if (m_colourScale == ColourScaleType::Linear &&
             m_normalization == ColumnNormalization::None) {
-            cparams.gain *= 2.f / float(getFFTSize());
+            //!!! This should not be necessary -- what is the actual range
+            cparams.maxValue = 0.1;
         }
         
         Colour3DPlotRenderer::Parameters params;
@@ -1469,10 +1470,16 @@
         params.normalization = m_normalization;
         params.binDisplay = m_binDisplay;
         params.binScale = m_binScale;
-        params.alwaysOpaque = false;
+        params.alwaysOpaque = false; //!!! should be true though
         params.invertVertical = false;
+        params.scaleFactor = 1.0;
         params.colourRotation = m_colourRotation;
 
+        if (m_colourScale != ColourScaleType::Phase &&
+            m_normalization == ColumnNormalization::None) {
+            params.scaleFactor *= 2.f / float(getFFTSize());
+        }
+
         Preferences::SpectrogramSmoothing smoothing = 
             Preferences::getInstance()->getSpectrogramSmoothing();
         params.interpolate = 
@@ -2063,6 +2070,11 @@
         if (dBmin < dBmax - 60.f) dBmin = dBmax - 60.f;
         bottom = QString("%1").arg(lrint(dBmin));
 
+#ifdef DEBUG_SPECTROGRAM_REPAINT
+        cerr << "adjusted dB range to min = " << dBmin << ", max = " << dBmax
+             << endl;
+#endif
+        
         //!!! & phase etc
 
         if (m_colourScale != ColourScaleType::Phase) {
@@ -2088,10 +2100,10 @@
             double dBval = dBmin + (((dBmax - dBmin) * i) / (ch - 1));
             int idb = int(dBval);
 
-//!!! replace this
-            // double value = AudioLevel::dB_to_multiplier(dBval);
-            // int colour = getDisplayValue(v, value * m_gain);
-	    // paint.setPen(m_palette.getColour((unsigned char)colour));
+            //!!!
+            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;