annotate layer/SpectrumLayer.h @ 216:34bbbcb3c01f sv1-1.0pre1

* Make getPropertyRangeAndValue return the default separately from the current value. Previously some contexts were incorrectly treating the current value as a default.
author Chris Cannam
date Fri, 02 Mar 2007 14:00:12 +0000
parents 45e995ed84d9
children 28c8e8e3c537
rev   line source
Chris@133 1
Chris@133 2 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@133 3
Chris@133 4 /*
Chris@133 5 Sonic Visualiser
Chris@133 6 An audio file viewer and annotation editor.
Chris@133 7 Centre for Digital Music, Queen Mary, University of London.
Chris@182 8 This file copyright 2006 QMUL.
Chris@133 9
Chris@133 10 This program is free software; you can redistribute it and/or
Chris@133 11 modify it under the terms of the GNU General Public License as
Chris@133 12 published by the Free Software Foundation; either version 2 of the
Chris@133 13 License, or (at your option) any later version. See the file
Chris@133 14 COPYING included with this distribution for more information.
Chris@133 15 */
Chris@133 16
Chris@133 17 #ifndef _SPECTRUM_LAYER_H_
Chris@133 18 #define _SPECTRUM_LAYER_H_
Chris@133 19
Chris@193 20 #include "SliceLayer.h"
Chris@133 21
Chris@153 22 #include "base/Window.h"
Chris@153 23
Chris@133 24 #include "data/model/DenseTimeValueModel.h"
Chris@133 25
Chris@133 26 #include <QColor>
Chris@133 27
Chris@133 28 class FFTModel;
Chris@133 29
Chris@193 30 class SpectrumLayer : public SliceLayer
Chris@133 31 {
Chris@133 32 Q_OBJECT
Chris@133 33
Chris@133 34 public:
Chris@133 35 SpectrumLayer();
Chris@133 36 ~SpectrumLayer();
Chris@133 37
Chris@133 38 void setModel(DenseTimeValueModel *model);
Chris@193 39 virtual const Model *getModel() const { return m_originModel; }
Chris@133 40
Chris@199 41 virtual QString getFeatureDescription(View *v, QPoint &) const;
Chris@199 42
Chris@153 43 virtual PropertyList getProperties() const;
Chris@153 44 virtual QString getPropertyLabel(const PropertyName &) const;
Chris@153 45 virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@153 46 virtual QString getPropertyGroupName(const PropertyName &) const;
Chris@153 47 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@216 48 int *min, int *max, int *deflt) const;
Chris@153 49 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@153 50 int value) const;
Chris@167 51 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
Chris@153 52 virtual void setProperty(const PropertyName &, int value);
Chris@133 53 virtual void setProperties(const QXmlAttributes &);
Chris@133 54
Chris@133 55 virtual bool getValueExtents(float &min, float &max,
Chris@133 56 bool &logarithmic, QString &unit) const;
Chris@133 57
Chris@133 58 virtual bool isLayerScrollable(const View *v) const { return false; }
Chris@133 59
Chris@153 60 void setChannel(int);
Chris@153 61 int getChannel() const { return m_channel; }
Chris@153 62
Chris@153 63 void setWindowSize(size_t);
Chris@153 64 size_t getWindowSize() const { return m_windowSize; }
Chris@153 65
Chris@153 66 void setWindowHopLevel(size_t level);
Chris@153 67 size_t getWindowHopLevel() const { return m_windowHopLevel; }
Chris@153 68
Chris@153 69 void setWindowType(WindowType type);
Chris@153 70 WindowType getWindowType() const { return m_windowType; }
Chris@153 71
Chris@153 72 virtual QString toXmlString(QString indent = "",
Chris@153 73 QString extraAttributes = "") const;
Chris@153 74
Chris@153 75 protected slots:
Chris@153 76 void preferenceChanged(PropertyContainer::PropertyName name);
Chris@133 77
Chris@133 78 protected:
Chris@193 79 // make this SliceLayer method unavailable to the general public
Chris@193 80 // virtual void setModel(DenseThreeDimensionalModel *model) {
Chris@193 81 // SliceLayer::setModel(model);
Chris@193 82 // }
Chris@193 83
Chris@193 84 DenseTimeValueModel *m_originModel;
Chris@153 85 int m_channel;
Chris@153 86 bool m_channelSet;
Chris@153 87 size_t m_windowSize;
Chris@153 88 WindowType m_windowType;
Chris@153 89 size_t m_windowHopLevel;
Chris@153 90
Chris@193 91 void setupFFT();
Chris@153 92
Chris@153 93 size_t getWindowIncrement() const {
Chris@153 94 if (m_windowHopLevel == 0) return m_windowSize;
Chris@153 95 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4;
Chris@153 96 else return m_windowSize / (1 << (m_windowHopLevel - 1));
Chris@153 97 }
Chris@133 98 };
Chris@133 99
Chris@133 100 #endif