annotate layer/SpectrumLayer.h @ 1388:81dda64a7edc spectrogramparam

Make mention of the shift-drag feature and zooming in the status text
author Chris Cannam
date Tue, 13 Nov 2018 13:39:01 +0000
parents fc3d89f88690
children 900bed394f5a
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@1238 17 #ifndef SV_SPECTRUM_LAYER_H
Chris@1238 18 #define SV_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@1276 26 #include "HorizontalScaleProvider.h"
Chris@1238 27
Chris@133 28 #include <QColor>
Chris@349 29 #include <QMutex>
Chris@133 30
Chris@1238 31 class SpectrumLayer : public SliceLayer,
Chris@1276 32 public HorizontalScaleProvider
Chris@133 33 {
Chris@133 34 Q_OBJECT
Chris@133 35
Chris@133 36 public:
Chris@133 37 SpectrumLayer();
Chris@133 38 ~SpectrumLayer();
Chris@133 39
Chris@133 40 void setModel(DenseTimeValueModel *model);
cannam@1241 41 virtual const Model *getModel() const override { return m_originModel; }
Chris@133 42
Chris@918 43 virtual bool getCrosshairExtents(LayerGeometryProvider *, QPainter &, QPoint cursorPos,
cannam@1241 44 std::vector<QRect> &extents) const override;
cannam@1241 45 virtual void paintCrosshairs(LayerGeometryProvider *, QPainter &, QPoint) const override;
Chris@254 46
Chris@1383 47 virtual int getHorizontalScaleHeight(LayerGeometryProvider *, QPainter &) const override;
Chris@1281 48 virtual void paintHorizontalScale(LayerGeometryProvider *, QPainter &, int xorigin) const;
Chris@1281 49
cannam@1241 50 virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const override;
Chris@199 51
cannam@1241 52 virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const override;
Chris@275 53
cannam@1241 54 virtual VerticalPosition getPreferredFrameCountPosition() const override {
Chris@1266 55 return PositionTop;
Chris@277 56 }
Chris@277 57
cannam@1241 58 virtual PropertyList getProperties() const override;
cannam@1241 59 virtual QString getPropertyLabel(const PropertyName &) const override;
cannam@1241 60 virtual QString getPropertyIconName(const PropertyName &) const override;
cannam@1241 61 virtual PropertyType getPropertyType(const PropertyName &) const override;
cannam@1241 62 virtual QString getPropertyGroupName(const PropertyName &) const override;
Chris@153 63 virtual int getPropertyRangeAndValue(const PropertyName &,
cannam@1241 64 int *min, int *max, int *deflt) const override;
Chris@153 65 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@1266 66 int value) const override;
cannam@1241 67 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const override;
cannam@1241 68 virtual void setProperty(const PropertyName &, int value) override;
cannam@1241 69 virtual void setProperties(const QXmlAttributes &) override;
Chris@133 70
Chris@918 71 virtual bool getXScaleValue(const LayerGeometryProvider *v, int x,
cannam@1241 72 double &value, QString &unit) const override;
Chris@260 73
Chris@918 74 virtual bool getYScaleValue(const LayerGeometryProvider *, int y,
cannam@1241 75 double &value, QString &unit) const override;
Chris@274 76
Chris@918 77 virtual bool getYScaleDifference(const LayerGeometryProvider *, int y0, int y1,
cannam@1241 78 double &diff, QString &unit) const override;
Chris@274 79
cannam@1241 80 virtual bool isLayerScrollable(const LayerGeometryProvider *) const override { return false; }
Chris@133 81
Chris@153 82 void setChannel(int);
Chris@153 83 int getChannel() const { return m_channel; }
Chris@153 84
Chris@805 85 void setWindowSize(int);
Chris@805 86 int getWindowSize() const { return m_windowSize; }
Chris@153 87
Chris@805 88 void setWindowHopLevel(int level);
Chris@805 89 int getWindowHopLevel() const { return m_windowHopLevel; }
Chris@153 90
Chris@1382 91 void setOversampling(int oversampling);
Chris@1382 92 int getOversampling() const;
Chris@1382 93
Chris@1382 94 int getFFTSize() const { return getWindowSize() * getOversampling(); }
Chris@1382 95
Chris@153 96 void setWindowType(WindowType type);
Chris@153 97 WindowType getWindowType() const { return m_windowType; }
Chris@1382 98
Chris@284 99 void setShowPeaks(bool);
Chris@284 100 bool getShowPeaks() const { return m_showPeaks; }
Chris@284 101
Chris@316 102 virtual void toXml(QTextStream &stream, QString indent = "",
cannam@1241 103 QString extraAttributes = "") const override;
Chris@153 104
Chris@1281 105 virtual double getFrequencyForX(const LayerGeometryProvider *, double x)
Chris@1281 106 const override;
Chris@1281 107 virtual double getXForFrequency(const LayerGeometryProvider *, double freq)
Chris@1281 108 const override;
Chris@1238 109
Chris@153 110 protected slots:
Chris@153 111 void preferenceChanged(PropertyContainer::PropertyName name);
Chris@133 112
Chris@133 113 protected:
Chris@193 114 DenseTimeValueModel *m_originModel;
Chris@153 115 int m_channel;
Chris@153 116 bool m_channelSet;
Chris@1362 117 int m_windowSize;
Chris@153 118 WindowType m_windowType;
Chris@1362 119 int m_windowHopLevel;
Chris@1382 120 int m_oversampling;
Chris@284 121 bool m_showPeaks;
Chris@275 122 mutable bool m_newFFTNeeded;
Chris@153 123
Chris@349 124 mutable QMutex m_fftMutex;
Chris@349 125
Chris@193 126 void setupFFT();
Chris@153 127
Chris@1386 128 virtual double getBinForFrequency(double freq) const;
Chris@1386 129 virtual double getFrequencyForBin(double bin) const;
Chris@1386 130
Chris@1386 131 virtual double getXForBin(const LayerGeometryProvider *, double bin)
Chris@1386 132 const override;
Chris@1386 133 virtual double getBinForX(const LayerGeometryProvider *, double x)
Chris@1386 134 const override;
Chris@1386 135
cannam@1241 136 virtual void getBiasCurve(BiasCurve &) const override;
Chris@254 137 BiasCurve m_biasCurve;
Chris@254 138
Chris@805 139 int getWindowIncrement() const {
Chris@153 140 if (m_windowHopLevel == 0) return m_windowSize;
Chris@153 141 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4;
Chris@153 142 else return m_windowSize / (1 << (m_windowHopLevel - 1));
Chris@153 143 }
Chris@133 144 };
Chris@133 145
Chris@133 146 #endif