Chris@1554: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@1554: Chris@1554: /* Chris@1554: Sonic Visualiser Chris@1554: An audio file viewer and annotation editor. Chris@1554: Centre for Digital Music, Queen Mary, University of London. Chris@1554: Chris@1554: This program is free software; you can redistribute it and/or Chris@1554: modify it under the terms of the GNU General Public License as Chris@1554: published by the Free Software Foundation; either version 2 of the Chris@1554: License, or (at your option) any later version. See the file Chris@1554: COPYING included with this distribution for more information. Chris@1554: */ Chris@1554: Chris@1554: #ifndef COLOUR_3D_PLOT_EXPORTER_H Chris@1554: #define COLOUR_3D_PLOT_EXPORTER_H Chris@1554: Chris@1554: #include "Colour3DPlotRenderer.h" Chris@1554: Chris@1554: class Colour3DPlotExporter : public Model Chris@1554: { Chris@1554: Q_OBJECT Chris@1554: Chris@1554: public: Chris@1554: struct Sources { Chris@1554: // These must all outlive this class, or else discardSources() Chris@1554: // must be called Chris@1554: const VerticalBinLayer *verticalBinLayer; // always Chris@1554: ModelId source; // always; a DenseThreeDimensionalModel Chris@1554: ModelId fft; // optionally; an FFTModel; used for phase/peak-freq modes Chris@1554: const LayerGeometryProvider *provider; // optionally Chris@1554: }; Chris@1554: Chris@1564: enum class TimestampFormat { Chris@1564: None, Chris@1564: Seconds, Chris@1564: Frames Chris@1564: }; Chris@1564: Chris@1554: struct Parameters { Chris@1554: Parameters() : Chris@1561: binDisplay(BinDisplay::AllBins), Chris@1561: scaleFactor(1.0), Chris@1561: threshold(0.0), Chris@1561: gain(1.0), Chris@1564: normalization(ColumnNormalization::None), Chris@1564: timestampFormat(TimestampFormat::None) { } Chris@1554: Chris@1554: /** Selection of bins to include in the export. */ Chris@1554: BinDisplay binDisplay; Chris@1561: Chris@1561: /** Initial scale factor (e.g. for FFT scaling). This factor Chris@1561: * is actually applied to exported values, in contrast to the Chris@1561: * gain value below based on the ColourScale parameter. */ Chris@1561: double scaleFactor; Chris@1561: Chris@1561: /** Threshold below which every value is mapped to background Chris@1561: * pixel 0 in the display, matching the ColourScale object Chris@1561: * parameters. This is used for thresholding in Chris@1561: * peak-frequency output only. */ Chris@1561: double threshold; Chris@1561: Chris@1561: /** Gain that is applied before thresholding, in the display, Chris@1561: * matching the ColourScale object parameters. This is used Chris@1561: * only to determined the thresholding level. The exported Chris@1561: * values have the scaleFactor applied, but not this gain. */ Chris@1561: double gain; Chris@1561: Chris@1561: /** Type of column normalization. Again, this is only used to Chris@1561: * calculate thresholding level. The exported values are Chris@1561: * un-normalized. */ Chris@1561: ColumnNormalization normalization; Chris@1564: Chris@1564: /** Format to use for the timestamp column. If None, no Chris@1564: * timestamp column will be included. */ Chris@1564: TimestampFormat timestampFormat; Chris@1554: }; Chris@1554: Chris@1556: Colour3DPlotExporter(Sources sources, Parameters parameters); Chris@1556: ~Colour3DPlotExporter(); Chris@1554: Chris@1556: void discardSources(); Chris@1565: Chris@1565: QString getDelimitedDataHeaderLine(QString, DataExportOptions) const override; Chris@1565: Chris@1554: QString toDelimitedDataString(QString, DataExportOptions, Chris@1554: sv_frame_t, sv_frame_t) const override; Chris@1554: Chris@1556: Chris@1556: // Further Model methods that we just delegate Chris@1556: Chris@1556: bool isOK() const override { Chris@1556: if (auto model = ModelById::get(m_sources.source)) { Chris@1556: return model->isOK(); Chris@1556: } Chris@1556: return false; Chris@1556: } Chris@1556: Chris@1556: sv_frame_t getStartFrame() const override { Chris@1556: if (auto model = ModelById::get(m_sources.source)) { Chris@1556: return model->getStartFrame(); Chris@1556: } Chris@1556: return 0; Chris@1556: } Chris@1556: Chris@1556: sv_frame_t getTrueEndFrame() const override { Chris@1556: if (auto model = ModelById::get(m_sources.source)) { Chris@1556: return model->getTrueEndFrame(); Chris@1556: } Chris@1556: return 0; Chris@1556: } Chris@1556: Chris@1556: sv_samplerate_t getSampleRate() const override { Chris@1556: if (auto model = ModelById::get(m_sources.source)) { Chris@1556: return model->getSampleRate(); Chris@1556: } Chris@1556: return 0; Chris@1556: } Chris@1556: Chris@1556: QString getTypeName() const override { Chris@1556: if (auto model = ModelById::get(m_sources.source)) { Chris@1556: return model->getTypeName(); Chris@1556: } Chris@1556: return "(exporter)"; // internal fallback, no translation needed Chris@1556: } Chris@1556: Chris@1556: int getCompletion() const override { Chris@1556: if (auto model = ModelById::get(m_sources.source)) { Chris@1556: return model->getCompletion(); Chris@1556: } Chris@1556: return 0; Chris@1556: } Chris@1556: Chris@1554: private: Chris@1554: Sources m_sources; Chris@1554: Parameters m_params; Chris@1554: }; Chris@1554: Chris@1554: #endif