lbajardsilogic@0: lbajardsilogic@0: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ lbajardsilogic@0: lbajardsilogic@0: /* lbajardsilogic@0: Sonic Visualiser lbajardsilogic@0: An audio file viewer and annotation editor. lbajardsilogic@0: Centre for Digital Music, Queen Mary, University of London. lbajardsilogic@0: This file copyright 2006 QMUL. lbajardsilogic@0: lbajardsilogic@0: This program is free software; you can redistribute it and/or lbajardsilogic@0: modify it under the terms of the GNU General Public License as lbajardsilogic@0: published by the Free Software Foundation; either version 2 of the lbajardsilogic@0: License, or (at your option) any later version. See the file lbajardsilogic@0: COPYING included with this distribution for more information. lbajardsilogic@0: */ lbajardsilogic@0: lbajardsilogic@0: #ifndef _SPECTRUM_LAYER_H_ lbajardsilogic@0: #define _SPECTRUM_LAYER_H_ lbajardsilogic@0: lbajardsilogic@0: #include "SliceLayer.h" lbajardsilogic@0: lbajardsilogic@0: #include "base/Window.h" lbajardsilogic@0: lbajardsilogic@0: #include "data/model/DenseTimeValueModel.h" lbajardsilogic@0: lbajardsilogic@0: #include lbajardsilogic@0: lbajardsilogic@0: class FFTModel; lbajardsilogic@0: lbajardsilogic@0: class SpectrumLayer : public SliceLayer lbajardsilogic@0: { lbajardsilogic@0: Q_OBJECT lbajardsilogic@0: lbajardsilogic@0: public: lbajardsilogic@0: SpectrumLayer(); lbajardsilogic@0: ~SpectrumLayer(); lbajardsilogic@0: lbajardsilogic@0: void setModel(DenseTimeValueModel *model); lbajardsilogic@0: virtual const Model *getModel() const { return m_originModel; } lbajardsilogic@0: lbajardsilogic@0: virtual QString getFeatureDescription(View *v, QPoint &) const; lbajardsilogic@0: lbajardsilogic@0: virtual PropertyList getProperties() const; lbajardsilogic@0: virtual QString getPropertyLabel(const PropertyName &) const; lbajardsilogic@0: virtual PropertyType getPropertyType(const PropertyName &) const; lbajardsilogic@0: virtual QString getPropertyGroupName(const PropertyName &) const; lbajardsilogic@0: virtual int getPropertyRangeAndValue(const PropertyName &, lbajardsilogic@0: int *min, int *max, int *deflt) const; lbajardsilogic@0: virtual QString getPropertyValueLabel(const PropertyName &, lbajardsilogic@0: int value) const; lbajardsilogic@0: virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; lbajardsilogic@0: virtual void setProperty(const PropertyName &, int value); lbajardsilogic@0: virtual void setProperties(const QXmlAttributes &); lbajardsilogic@0: lbajardsilogic@0: virtual bool getValueExtents(float &min, float &max, lbajardsilogic@0: bool &logarithmic, QString &unit) const; lbajardsilogic@0: lbajardsilogic@0: virtual bool isLayerScrollable(const View *) const { return false; } lbajardsilogic@0: lbajardsilogic@0: void setChannel(int); lbajardsilogic@0: int getChannel() const { return m_channel; } lbajardsilogic@0: lbajardsilogic@0: void setWindowSize(size_t); lbajardsilogic@0: size_t getWindowSize() const { return m_windowSize; } lbajardsilogic@0: lbajardsilogic@0: void setWindowHopLevel(size_t level); lbajardsilogic@0: size_t getWindowHopLevel() const { return m_windowHopLevel; } lbajardsilogic@0: lbajardsilogic@0: void setWindowType(WindowType type); lbajardsilogic@0: WindowType getWindowType() const { return m_windowType; } lbajardsilogic@0: lbajardsilogic@0: virtual QString toXmlString(QString indent = "", lbajardsilogic@0: QString extraAttributes = "") const; lbajardsilogic@0: lbajardsilogic@0: protected slots: lbajardsilogic@0: void preferenceChanged(PropertyContainer::PropertyName name); lbajardsilogic@0: lbajardsilogic@0: protected: lbajardsilogic@0: // make this SliceLayer method unavailable to the general public lbajardsilogic@0: // virtual void setModel(DenseThreeDimensionalModel *model) { lbajardsilogic@0: // SliceLayer::setModel(model); lbajardsilogic@0: // } lbajardsilogic@0: lbajardsilogic@0: DenseTimeValueModel *m_originModel; lbajardsilogic@0: int m_channel; lbajardsilogic@0: bool m_channelSet; lbajardsilogic@0: size_t m_windowSize; lbajardsilogic@0: WindowType m_windowType; lbajardsilogic@0: size_t m_windowHopLevel; lbajardsilogic@0: lbajardsilogic@0: void setupFFT(); lbajardsilogic@0: lbajardsilogic@0: size_t getWindowIncrement() const { lbajardsilogic@0: if (m_windowHopLevel == 0) return m_windowSize; lbajardsilogic@0: else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4; lbajardsilogic@0: else return m_windowSize / (1 << (m_windowHopLevel - 1)); lbajardsilogic@0: } lbajardsilogic@0: }; lbajardsilogic@0: lbajardsilogic@0: #endif