Chris@133: Chris@133: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@133: Chris@133: /* Chris@133: Sonic Visualiser Chris@133: An audio file viewer and annotation editor. Chris@133: Centre for Digital Music, Queen Mary, University of London. Chris@182: This file copyright 2006 QMUL. Chris@133: Chris@133: This program is free software; you can redistribute it and/or Chris@133: modify it under the terms of the GNU General Public License as Chris@133: published by the Free Software Foundation; either version 2 of the Chris@133: License, or (at your option) any later version. See the file Chris@133: COPYING included with this distribution for more information. Chris@133: */ Chris@133: Chris@133: #ifndef _SPECTRUM_LAYER_H_ Chris@133: #define _SPECTRUM_LAYER_H_ Chris@133: Chris@193: #include "SliceLayer.h" Chris@133: Chris@153: #include "base/Window.h" Chris@153: Chris@133: #include "data/model/DenseTimeValueModel.h" Chris@133: Chris@133: #include Chris@349: #include Chris@133: Chris@133: class FFTModel; Chris@133: Chris@193: class SpectrumLayer : public SliceLayer Chris@133: { Chris@133: Q_OBJECT Chris@133: Chris@133: public: Chris@133: SpectrumLayer(); Chris@133: ~SpectrumLayer(); Chris@133: Chris@133: void setModel(DenseTimeValueModel *model); Chris@193: virtual const Model *getModel() const { return m_originModel; } Chris@133: Chris@918: virtual bool getCrosshairExtents(LayerGeometryProvider *, QPainter &, QPoint cursorPos, Chris@254: std::vector &extents) const; Chris@918: virtual void paintCrosshairs(LayerGeometryProvider *, QPainter &, QPoint) const; Chris@254: Chris@918: virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const; Chris@199: Chris@916: virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; Chris@275: Chris@277: virtual VerticalPosition getPreferredFrameCountPosition() const { Chris@277: return PositionTop; Chris@277: } Chris@277: Chris@153: virtual PropertyList getProperties() const; Chris@153: virtual QString getPropertyLabel(const PropertyName &) const; Chris@335: virtual QString getPropertyIconName(const PropertyName &) const; Chris@153: virtual PropertyType getPropertyType(const PropertyName &) const; Chris@153: virtual QString getPropertyGroupName(const PropertyName &) const; Chris@153: virtual int getPropertyRangeAndValue(const PropertyName &, Chris@216: int *min, int *max, int *deflt) const; Chris@153: virtual QString getPropertyValueLabel(const PropertyName &, Chris@153: int value) const; Chris@167: virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; Chris@153: virtual void setProperty(const PropertyName &, int value); Chris@133: virtual void setProperties(const QXmlAttributes &); Chris@133: Chris@905: virtual bool getValueExtents(double &min, double &max, Chris@133: bool &logarithmic, QString &unit) const; Chris@133: Chris@918: virtual bool getXScaleValue(const LayerGeometryProvider *v, int x, Chris@905: double &value, QString &unit) const; Chris@260: Chris@918: virtual bool getYScaleValue(const LayerGeometryProvider *, int y, Chris@905: double &value, QString &unit) const; Chris@274: Chris@918: virtual bool getYScaleDifference(const LayerGeometryProvider *, int y0, int y1, Chris@905: double &diff, QString &unit) const; Chris@274: Chris@918: virtual bool isLayerScrollable(const LayerGeometryProvider *) const { return false; } Chris@133: Chris@153: void setChannel(int); Chris@153: int getChannel() const { return m_channel; } Chris@153: Chris@805: void setWindowSize(int); Chris@805: int getWindowSize() const { return m_windowSize; } Chris@153: Chris@805: void setWindowHopLevel(int level); Chris@805: int getWindowHopLevel() const { return m_windowHopLevel; } Chris@153: Chris@153: void setWindowType(WindowType type); Chris@153: WindowType getWindowType() const { return m_windowType; } Chris@153: Chris@284: void setShowPeaks(bool); Chris@284: bool getShowPeaks() const { return m_showPeaks; } Chris@284: Chris@918: virtual int getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &) const { return 0; } Chris@607: Chris@316: virtual void toXml(QTextStream &stream, QString indent = "", Chris@316: QString extraAttributes = "") const; Chris@153: Chris@153: protected slots: Chris@153: void preferenceChanged(PropertyContainer::PropertyName name); Chris@133: Chris@133: protected: Chris@193: // make this SliceLayer method unavailable to the general public Chris@193: // virtual void setModel(DenseThreeDimensionalModel *model) { Chris@193: // SliceLayer::setModel(model); Chris@193: // } Chris@193: Chris@193: DenseTimeValueModel *m_originModel; Chris@153: int m_channel; Chris@153: bool m_channelSet; Chris@805: int m_windowSize; Chris@153: WindowType m_windowType; Chris@805: int m_windowHopLevel; Chris@284: bool m_showPeaks; Chris@275: mutable bool m_newFFTNeeded; Chris@153: Chris@349: mutable QMutex m_fftMutex; Chris@349: Chris@193: void setupFFT(); Chris@153: Chris@254: virtual void getBiasCurve(BiasCurve &) const; Chris@254: BiasCurve m_biasCurve; Chris@254: Chris@905: virtual double getXForBin(int bin, int totalBins, double w) const; Chris@905: virtual int getBinForX(double x, int totalBins, double w) const; Chris@265: Chris@905: double getFrequencyForX(double x, double w) const; Chris@905: double getXForFrequency(double freq, double w) const; Chris@254: Chris@805: int getWindowIncrement() const { Chris@153: if (m_windowHopLevel == 0) return m_windowSize; Chris@153: else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4; Chris@153: else return m_windowSize / (1 << (m_windowHopLevel - 1)); Chris@153: } Chris@133: }; Chris@133: Chris@133: #endif