# HG changeset patch # User Chris Cannam # Date 1578580541 0 # Node ID 3b45788b78046e8cf5f5cbeb7e64137ecdcc8a81 # Parent d6f9fac336b37d195066a1ed189d8d0cb06a5929 Provide parameters needed for scale and thresholding diff -r d6f9fac336b3 -r 3b45788b7804 layer/SpectrogramLayer.cpp --- 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(sources, params)); diff -r d6f9fac336b3 -r 3b45788b7804 layer/SpectrogramLayer.h --- 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 m_exporters; // used and waiting to be released + + mutable std::vector m_exporters; // used, waiting to be released + void checkCacheSpace(int *suggestedPeakDivisor, bool *createWholeCache) const; void recreateFFTModel();