comparison layer/SpectrumLayer.h @ 153:aaa3a53dbb10

* Some work on SpectrumLayer properties etc
author Chris Cannam
date Wed, 27 Sep 2006 14:56:31 +0000
parents 9e6b3e239b9d
children 53b9c7656798
comparison
equal deleted inserted replaced
152:6a3f3c13173f 153:aaa3a53dbb10
17 #ifndef _SPECTRUM_LAYER_H_ 17 #ifndef _SPECTRUM_LAYER_H_
18 #define _SPECTRUM_LAYER_H_ 18 #define _SPECTRUM_LAYER_H_
19 19
20 #include "Layer.h" 20 #include "Layer.h"
21 21
22 #include "base/Window.h"
23
22 #include "data/model/DenseTimeValueModel.h" 24 #include "data/model/DenseTimeValueModel.h"
23 25
24 #include <QColor> 26 #include <QColor>
25 27
26 class FFTModel; 28 class FFTModel;
35 37
36 void setModel(DenseTimeValueModel *model); 38 void setModel(DenseTimeValueModel *model);
37 virtual const Model *getModel() const { return m_model; } 39 virtual const Model *getModel() const { return m_model; }
38 virtual void paint(View *v, QPainter &paint, QRect rect) const; 40 virtual void paint(View *v, QPainter &paint, QRect rect) const;
39 41
42 virtual PropertyList getProperties() const;
43 virtual QString getPropertyLabel(const PropertyName &) const;
44 virtual PropertyType getPropertyType(const PropertyName &) const;
45 virtual QString getPropertyGroupName(const PropertyName &) const;
46 virtual int getPropertyRangeAndValue(const PropertyName &,
47 int *min, int *max) const;
48 virtual QString getPropertyValueLabel(const PropertyName &,
49 int value) const;
50 virtual void setProperty(const PropertyName &, int value);
40 virtual void setProperties(const QXmlAttributes &); 51 virtual void setProperties(const QXmlAttributes &);
41 52
42 virtual bool getValueExtents(float &min, float &max, 53 virtual bool getValueExtents(float &min, float &max,
43 bool &logarithmic, QString &unit) const; 54 bool &logarithmic, QString &unit) const;
44 55
45 virtual bool isLayerScrollable(const View *v) const { return false; } 56 virtual bool isLayerScrollable(const View *v) const { return false; }
46 57
47 virtual QString getPropertyLabel(const PropertyName &) const { return ""; } 58 enum ChannelMode { SeparateChannels, MixChannels, OverlayChannels };
59
60 void setChannelMode(ChannelMode);
61 ChannelMode getChannelCount() const { return m_channelMode; }
62
63 void setChannel(int);
64 int getChannel() const { return m_channel; }
65
66 enum EnergyScale { LinearScale, MeterScale, dBScale };
67
68 void setBaseColour(QColor);
69 QColor getBaseColour() const { return m_colour; }
70
71 void setEnergyScale(EnergyScale);
72 EnergyScale getEnergyScale() const { return m_energyScale; }
73
74 void setWindowSize(size_t);
75 size_t getWindowSize() const { return m_windowSize; }
76
77 void setWindowHopLevel(size_t level);
78 size_t getWindowHopLevel() const { return m_windowHopLevel; }
79
80 void setWindowType(WindowType type);
81 WindowType getWindowType() const { return m_windowType; }
82
83 void setGain(float gain);
84 float getGain() const;
85
86 void setNormalize(bool n);
87 bool getNormalize() const;
88
89 virtual QString toXmlString(QString indent = "",
90 QString extraAttributes = "") const;
91
92 protected slots:
93 void preferenceChanged(PropertyContainer::PropertyName name);
48 94
49 protected: 95 protected:
50 DenseTimeValueModel *m_model; 96 DenseTimeValueModel *m_model;
51 FFTModel *m_fft; 97 std::vector<FFTModel *> m_fft;
52 QColor m_colour; 98 ChannelMode m_channelMode;
99 int m_channel;
100 bool m_channelSet;
101 QColor m_colour;
102 EnergyScale m_energyScale;
103 bool m_normalize;
104 float m_gain;
105 size_t m_windowSize;
106 WindowType m_windowType;
107 size_t m_windowHopLevel;
108
109 void setupFFTs();
110
111 size_t getWindowIncrement() const {
112 if (m_windowHopLevel == 0) return m_windowSize;
113 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4;
114 else return m_windowSize / (1 << (m_windowHopLevel - 1));
115 }
53 }; 116 };
54 117
55 #endif 118 #endif