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@133: This file copyright 2006 Chris Cannam. 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@133: #include "Layer.h" Chris@133: Chris@153: #include "base/Window.h" Chris@153: Chris@133: #include "data/model/DenseTimeValueModel.h" Chris@133: Chris@133: #include Chris@133: Chris@133: class FFTModel; Chris@133: Chris@133: class SpectrumLayer : public Layer 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@133: virtual const Model *getModel() const { return m_model; } Chris@133: virtual void paint(View *v, QPainter &paint, QRect rect) const; Chris@133: Chris@153: virtual PropertyList getProperties() const; Chris@153: virtual QString getPropertyLabel(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@153: int *min, int *max) 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@133: virtual bool getValueExtents(float &min, float &max, Chris@133: bool &logarithmic, QString &unit) const; Chris@133: Chris@133: virtual bool isLayerScrollable(const View *v) const { return false; } Chris@133: Chris@153: enum ChannelMode { SeparateChannels, MixChannels, OverlayChannels }; Chris@153: Chris@153: void setChannelMode(ChannelMode); Chris@153: ChannelMode getChannelCount() const { return m_channelMode; } Chris@153: Chris@153: void setChannel(int); Chris@153: int getChannel() const { return m_channel; } Chris@153: Chris@153: enum EnergyScale { LinearScale, MeterScale, dBScale }; Chris@153: Chris@153: void setBaseColour(QColor); Chris@153: QColor getBaseColour() const { return m_colour; } Chris@153: Chris@153: void setEnergyScale(EnergyScale); Chris@153: EnergyScale getEnergyScale() const { return m_energyScale; } Chris@153: Chris@153: void setWindowSize(size_t); Chris@153: size_t getWindowSize() const { return m_windowSize; } Chris@153: Chris@153: void setWindowHopLevel(size_t level); Chris@153: size_t getWindowHopLevel() const { return m_windowHopLevel; } Chris@153: Chris@153: void setWindowType(WindowType type); Chris@153: WindowType getWindowType() const { return m_windowType; } Chris@153: Chris@153: void setGain(float gain); Chris@153: float getGain() const; Chris@153: Chris@153: void setNormalize(bool n); Chris@153: bool getNormalize() const; Chris@153: Chris@153: virtual QString toXmlString(QString indent = "", Chris@153: QString extraAttributes = "") const; Chris@153: Chris@153: protected slots: Chris@153: void preferenceChanged(PropertyContainer::PropertyName name); Chris@133: Chris@133: protected: Chris@153: DenseTimeValueModel *m_model; Chris@153: std::vector m_fft; Chris@153: ChannelMode m_channelMode; Chris@153: int m_channel; Chris@153: bool m_channelSet; Chris@153: QColor m_colour; Chris@153: EnergyScale m_energyScale; Chris@153: bool m_normalize; Chris@153: float m_gain; Chris@153: size_t m_windowSize; Chris@153: WindowType m_windowType; Chris@153: size_t m_windowHopLevel; Chris@153: Chris@153: void setupFFTs(); Chris@153: Chris@153: size_t 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