annotate layer/SpectrumLayer.h @ 154:30d624900564

* Introduce WritableWaveFileModel, and use it as an output model for audio real-time plugin transforms. Updates aren't working correctly yet.
author Chris Cannam
date Tue, 03 Oct 2006 14:17:37 +0000
parents aaa3a53dbb10
children 53b9c7656798
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@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@153 50 virtual void setProperty(const PropertyName &, int value);
Chris@133 51 virtual void setProperties(const QXmlAttributes &);
Chris@133 52
Chris@133 53 virtual bool getValueExtents(float &min, float &max,
Chris@133 54 bool &logarithmic, QString &unit) const;
Chris@133 55
Chris@133 56 virtual bool isLayerScrollable(const View *v) const { return false; }
Chris@133 57
Chris@153 58 enum ChannelMode { SeparateChannels, MixChannels, OverlayChannels };
Chris@153 59
Chris@153 60 void setChannelMode(ChannelMode);
Chris@153 61 ChannelMode getChannelCount() const { return m_channelMode; }
Chris@153 62
Chris@153 63 void setChannel(int);
Chris@153 64 int getChannel() const { return m_channel; }
Chris@153 65
Chris@153 66 enum EnergyScale { LinearScale, MeterScale, dBScale };
Chris@153 67
Chris@153 68 void setBaseColour(QColor);
Chris@153 69 QColor getBaseColour() const { return m_colour; }
Chris@153 70
Chris@153 71 void setEnergyScale(EnergyScale);
Chris@153 72 EnergyScale getEnergyScale() const { return m_energyScale; }
Chris@153 73
Chris@153 74 void setWindowSize(size_t);
Chris@153 75 size_t getWindowSize() const { return m_windowSize; }
Chris@153 76
Chris@153 77 void setWindowHopLevel(size_t level);
Chris@153 78 size_t getWindowHopLevel() const { return m_windowHopLevel; }
Chris@153 79
Chris@153 80 void setWindowType(WindowType type);
Chris@153 81 WindowType getWindowType() const { return m_windowType; }
Chris@153 82
Chris@153 83 void setGain(float gain);
Chris@153 84 float getGain() const;
Chris@153 85
Chris@153 86 void setNormalize(bool n);
Chris@153 87 bool getNormalize() const;
Chris@153 88
Chris@153 89 virtual QString toXmlString(QString indent = "",
Chris@153 90 QString extraAttributes = "") const;
Chris@153 91
Chris@153 92 protected slots:
Chris@153 93 void preferenceChanged(PropertyContainer::PropertyName name);
Chris@133 94
Chris@133 95 protected:
Chris@153 96 DenseTimeValueModel *m_model;
Chris@153 97 std::vector<FFTModel *> m_fft;
Chris@153 98 ChannelMode m_channelMode;
Chris@153 99 int m_channel;
Chris@153 100 bool m_channelSet;
Chris@153 101 QColor m_colour;
Chris@153 102 EnergyScale m_energyScale;
Chris@153 103 bool m_normalize;
Chris@153 104 float m_gain;
Chris@153 105 size_t m_windowSize;
Chris@153 106 WindowType m_windowType;
Chris@153 107 size_t m_windowHopLevel;
Chris@153 108
Chris@153 109 void setupFFTs();
Chris@153 110
Chris@153 111 size_t getWindowIncrement() const {
Chris@153 112 if (m_windowHopLevel == 0) return m_windowSize;
Chris@153 113 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4;
Chris@153 114 else return m_windowSize / (1 << (m_windowHopLevel - 1));
Chris@153 115 }
Chris@133 116 };
Chris@133 117
Chris@133 118 #endif