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@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@199: virtual QString getFeatureDescription(View *v, QPoint &) const; Chris@199: 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: void setChannel(int); Chris@153: int getChannel() const { return m_channel; } 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: 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@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@153: size_t m_windowSize; Chris@153: WindowType m_windowType; Chris@153: size_t m_windowHopLevel; Chris@153: Chris@193: void setupFFT(); 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