changeset 1562:3b45788b7804 spectrogram-export

Provide parameters needed for scale and thresholding
author Chris Cannam
date Thu, 09 Jan 2020 14:35:41 +0000
parents d6f9fac336b3
children 563bab925c9b
files layer/SpectrogramLayer.cpp layer/SpectrogramLayer.h
diffstat 2 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Thu Jan 09 14:34:51 2020 +0000
+++ b/layer/SpectrogramLayer.cpp	Thu Jan 09 14:35:41 2020 +0000
@@ -146,14 +146,13 @@
 ModelId
 SpectrogramLayer::getExportModel(LayerGeometryProvider *v) const
 {
-    //!!! Creating Colour3DPlotExporters is cheap, so perhaps we
-    // should create one on every call - calls probably being
-    // infrequent - to avoid having to worry about view lifecycles. We
-    // can't delete them on the same call of course as we need to
-    // return a valid id, so we could push them onto a list that then
-    // gets cleared (with calls to
+    // Creating Colour3DPlotExporters is cheap, so we create one on
+    // every call - calls probably being infrequent - to avoid having
+    // to worry about view lifecycles. We can't delete them on the
+    // same call of course as we need to return a valid id, so we push
+    // them onto a list that then gets cleared (with calls to
     // Colour3DPlotExporter::discardSources() and
-    // ModelById::release()) in deleteDerivedModels()
+    // ModelById::release()) in deleteDerivedModels().
 
     Colour3DPlotExporter::Sources sources;
     sources.verticalBinLayer = this;
@@ -163,6 +162,14 @@
         
     Colour3DPlotExporter::Parameters params;
     params.binDisplay = m_binDisplay;
+    params.scaleFactor = 1.0;
+    if (m_colourScale != ColourScaleType::Phase &&
+        m_normalization != ColumnNormalization::Hybrid) {
+        params.scaleFactor *= 2.f / float(getWindowSize());
+    }
+    params.threshold = m_threshold; // matching ColourScale in getRenderer
+    params.gain = m_gain; // matching ColourScale in getRenderer
+    params.normalization = m_normalization;
     
     ModelId exporter = ModelById::add
         (std::make_shared<Colour3DPlotExporter>(sources, params));
--- a/layer/SpectrogramLayer.h	Thu Jan 09 14:34:51 2020 +0000
+++ b/layer/SpectrogramLayer.h	Thu Jan 09 14:35:41 2020 +0000
@@ -334,7 +334,9 @@
     ModelId m_wholeCache; // a Dense3DModelPeakCache
     ModelId m_peakCache; // a Dense3DModelPeakCache
     int m_peakCacheDivisor;
-    mutable std::vector<ModelId> m_exporters; // used and waiting to be released
+    
+    mutable std::vector<ModelId> m_exporters; // used, waiting to be released
+    
     void checkCacheSpace(int *suggestedPeakDivisor,
                          bool *createWholeCache) const;
     void recreateFFTModel();