comparison layer/SpectrogramLayer.cpp @ 1562:3b45788b7804 spectrogram-export

Provide parameters needed for scale and thresholding
author Chris Cannam
date Thu, 09 Jan 2020 14:35:41 +0000
parents 745be36202aa
children
comparison
equal deleted inserted replaced
1561:d6f9fac336b3 1562:3b45788b7804
144 } 144 }
145 145
146 ModelId 146 ModelId
147 SpectrogramLayer::getExportModel(LayerGeometryProvider *v) const 147 SpectrogramLayer::getExportModel(LayerGeometryProvider *v) const
148 { 148 {
149 //!!! Creating Colour3DPlotExporters is cheap, so perhaps we 149 // Creating Colour3DPlotExporters is cheap, so we create one on
150 // should create one on every call - calls probably being 150 // every call - calls probably being infrequent - to avoid having
151 // infrequent - to avoid having to worry about view lifecycles. We 151 // to worry about view lifecycles. We can't delete them on the
152 // can't delete them on the same call of course as we need to 152 // same call of course as we need to return a valid id, so we push
153 // return a valid id, so we could push them onto a list that then 153 // them onto a list that then gets cleared (with calls to
154 // gets cleared (with calls to
155 // Colour3DPlotExporter::discardSources() and 154 // Colour3DPlotExporter::discardSources() and
156 // ModelById::release()) in deleteDerivedModels() 155 // ModelById::release()) in deleteDerivedModels().
157 156
158 Colour3DPlotExporter::Sources sources; 157 Colour3DPlotExporter::Sources sources;
159 sources.verticalBinLayer = this; 158 sources.verticalBinLayer = this;
160 sources.fft = m_fftModel; 159 sources.fft = m_fftModel;
161 sources.source = sources.fft; 160 sources.source = sources.fft;
162 sources.provider = v; 161 sources.provider = v;
163 162
164 Colour3DPlotExporter::Parameters params; 163 Colour3DPlotExporter::Parameters params;
165 params.binDisplay = m_binDisplay; 164 params.binDisplay = m_binDisplay;
165 params.scaleFactor = 1.0;
166 if (m_colourScale != ColourScaleType::Phase &&
167 m_normalization != ColumnNormalization::Hybrid) {
168 params.scaleFactor *= 2.f / float(getWindowSize());
169 }
170 params.threshold = m_threshold; // matching ColourScale in getRenderer
171 params.gain = m_gain; // matching ColourScale in getRenderer
172 params.normalization = m_normalization;
166 173
167 ModelId exporter = ModelById::add 174 ModelId exporter = ModelById::add
168 (std::make_shared<Colour3DPlotExporter>(sources, params)); 175 (std::make_shared<Colour3DPlotExporter>(sources, params));
169 m_exporters.push_back(exporter); 176 m_exporters.push_back(exporter);
170 return exporter; 177 return exporter;