changeset 1364:7d28e7522dbd

Add show-derivative option but, like inverting the colour scale, I don't think it's as useful as I'd hoped
author Chris Cannam
date Tue, 30 Oct 2018 15:32:01 +0000
parents bbeffb29bf09
children a1393b4384a5
files layer/Colour3DPlotRenderer.cpp layer/Colour3DPlotRenderer.h
diffstat 2 files changed, 39 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotRenderer.cpp	Tue Oct 30 14:00:20 2018 +0000
+++ b/layer/Colour3DPlotRenderer.cpp	Tue Oct 30 15:32:01 2018 +0000
@@ -353,8 +353,6 @@
 Colour3DPlotRenderer::getColumn(int sx, int minbin, int nbins,
                                 int peakCacheIndex) const
 {
-    Profiler profiler("Colour3DPlotRenderer::getColumn");
-    
     // order:
     // get column -> scale -> normalise -> record extents ->
     // peak pick -> distribute/interpolate -> apply display gain
@@ -363,7 +361,38 @@
     // get column -> scale -> normalise
 
     ColumnOp::Column column;
-                
+    
+    if (m_params.showDerivative && sx > 0) {
+
+        auto prev = getColumnRaw(sx - 1, minbin, nbins, peakCacheIndex);
+        column = getColumnRaw(sx, minbin, nbins, peakCacheIndex);
+        
+        for (int i = 0; i < nbins; ++i) {
+            column[i] -= prev[i];
+        }
+
+    } else {
+        column = getColumnRaw(sx, minbin, nbins, peakCacheIndex);
+    }
+
+    if (m_params.colourScale.getScale() == ColourScaleType::Phase &&
+        m_sources.fft) {
+        return column;
+    } else {
+        column = ColumnOp::applyGain(column, m_params.scaleFactor);
+        column = ColumnOp::normalize(column, m_params.normalization);
+        return column;
+    }
+}
+
+ColumnOp::Column
+Colour3DPlotRenderer::getColumnRaw(int sx, int minbin, int nbins,
+                                   int peakCacheIndex) const
+{
+    Profiler profiler("Colour3DPlotRenderer::getColumn");
+
+    ColumnOp::Column column;
+
     if (m_params.colourScale.getScale() == ColourScaleType::Phase &&
         m_sources.fft) {
 
@@ -382,10 +411,6 @@
                 
         column = vector<float>(fullColumn.data() + minbin,
                                fullColumn.data() + minbin + nbins);
-
-        column = ColumnOp::applyGain(column, m_params.scaleFactor);
-
-        column = ColumnOp::normalize(column, m_params.normalization);
     }
 
     return column;
--- a/layer/Colour3DPlotRenderer.h	Tue Oct 30 14:00:20 2018 +0000
+++ b/layer/Colour3DPlotRenderer.h	Tue Oct 30 15:32:01 2018 +0000
@@ -67,6 +67,7 @@
             alwaysOpaque(false),
             interpolate(false),
             invertVertical(false),
+            showDerivative(false),
             scaleFactor(1.0),
             colourRotation(0) { }
 
@@ -100,6 +101,10 @@
         /** Whether to render the whole caboodle upside-down. */
         bool invertVertical;
 
+        /** Whether to show the frame-to-frame difference instead of
+         *  the actual value */
+        bool showDerivative;
+
         /** Initial scale factor (e.g. for FFT scaling). This factor
          *  is applied to all values read from the underlying model
          *  *before* magnitude ranges are calculated, in contrast to
@@ -319,6 +324,8 @@
     
     ColumnOp::Column getColumn(int sx, int minbin, int nbins,
                                int peakCacheIndex) const; // -1 => don't use cache
+    ColumnOp::Column getColumnRaw(int sx, int minbin, int nbins,
+                                  int peakCacheIndex) const; // -1 => don't use cache
 
     void getPreferredPeakCache(const LayerGeometryProvider *,
                                int &peakCacheIndex, int &binsPerPeak) const;