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@133
|
8 This file copyright 2006 Chris Cannam.
|
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@133
|
20 #include "Layer.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@133
|
30 class SpectrumLayer : public Layer
|
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@133
|
39 virtual const Model *getModel() const { return m_model; }
|
Chris@133
|
40 virtual void paint(View *v, QPainter &paint, QRect rect) const;
|
Chris@133
|
41
|
Chris@153
|
42 virtual PropertyList getProperties() const;
|
Chris@153
|
43 virtual QString getPropertyLabel(const PropertyName &) const;
|
Chris@153
|
44 virtual PropertyType getPropertyType(const PropertyName &) const;
|
Chris@153
|
45 virtual QString getPropertyGroupName(const PropertyName &) const;
|
Chris@153
|
46 virtual int getPropertyRangeAndValue(const PropertyName &,
|
Chris@153
|
47 int *min, int *max) const;
|
Chris@153
|
48 virtual QString getPropertyValueLabel(const PropertyName &,
|
Chris@153
|
49 int value) const;
|
Chris@167
|
50 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
|
Chris@153
|
51 virtual void setProperty(const PropertyName &, int value);
|
Chris@133
|
52 virtual void setProperties(const QXmlAttributes &);
|
Chris@133
|
53
|
Chris@133
|
54 virtual bool getValueExtents(float &min, float &max,
|
Chris@133
|
55 bool &logarithmic, QString &unit) const;
|
Chris@133
|
56
|
Chris@133
|
57 virtual bool isLayerScrollable(const View *v) const { return false; }
|
Chris@133
|
58
|
Chris@153
|
59 enum ChannelMode { SeparateChannels, MixChannels, OverlayChannels };
|
Chris@153
|
60
|
Chris@153
|
61 void setChannelMode(ChannelMode);
|
Chris@153
|
62 ChannelMode getChannelCount() const { return m_channelMode; }
|
Chris@153
|
63
|
Chris@153
|
64 void setChannel(int);
|
Chris@153
|
65 int getChannel() const { return m_channel; }
|
Chris@153
|
66
|
Chris@153
|
67 enum EnergyScale { LinearScale, MeterScale, dBScale };
|
Chris@153
|
68
|
Chris@153
|
69 void setBaseColour(QColor);
|
Chris@153
|
70 QColor getBaseColour() const { return m_colour; }
|
Chris@153
|
71
|
Chris@153
|
72 void setEnergyScale(EnergyScale);
|
Chris@153
|
73 EnergyScale getEnergyScale() const { return m_energyScale; }
|
Chris@153
|
74
|
Chris@153
|
75 void setWindowSize(size_t);
|
Chris@153
|
76 size_t getWindowSize() const { return m_windowSize; }
|
Chris@153
|
77
|
Chris@153
|
78 void setWindowHopLevel(size_t level);
|
Chris@153
|
79 size_t getWindowHopLevel() const { return m_windowHopLevel; }
|
Chris@153
|
80
|
Chris@153
|
81 void setWindowType(WindowType type);
|
Chris@153
|
82 WindowType getWindowType() const { return m_windowType; }
|
Chris@153
|
83
|
Chris@153
|
84 void setGain(float gain);
|
Chris@153
|
85 float getGain() const;
|
Chris@153
|
86
|
Chris@153
|
87 void setNormalize(bool n);
|
Chris@153
|
88 bool getNormalize() const;
|
Chris@153
|
89
|
Chris@153
|
90 virtual QString toXmlString(QString indent = "",
|
Chris@153
|
91 QString extraAttributes = "") const;
|
Chris@153
|
92
|
Chris@153
|
93 protected slots:
|
Chris@153
|
94 void preferenceChanged(PropertyContainer::PropertyName name);
|
Chris@133
|
95
|
Chris@133
|
96 protected:
|
Chris@153
|
97 DenseTimeValueModel *m_model;
|
Chris@153
|
98 std::vector<FFTModel *> m_fft;
|
Chris@153
|
99 ChannelMode m_channelMode;
|
Chris@153
|
100 int m_channel;
|
Chris@153
|
101 bool m_channelSet;
|
Chris@153
|
102 QColor m_colour;
|
Chris@153
|
103 EnergyScale m_energyScale;
|
Chris@153
|
104 bool m_normalize;
|
Chris@153
|
105 float m_gain;
|
Chris@153
|
106 size_t m_windowSize;
|
Chris@153
|
107 WindowType m_windowType;
|
Chris@153
|
108 size_t m_windowHopLevel;
|
Chris@153
|
109
|
Chris@153
|
110 void setupFFTs();
|
Chris@153
|
111
|
Chris@153
|
112 size_t getWindowIncrement() const {
|
Chris@153
|
113 if (m_windowHopLevel == 0) return m_windowSize;
|
Chris@153
|
114 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4;
|
Chris@153
|
115 else return m_windowSize / (1 << (m_windowHopLevel - 1));
|
Chris@153
|
116 }
|
Chris@133
|
117 };
|
Chris@133
|
118
|
Chris@133
|
119 #endif
|