annotate layer/SpectrumLayer.h @ 592:a13aa5320221 sonification

Extends the audio feedback of the piano scale to the Spectrum layer (horizontal piano keyboard). Increase of the piano keyboard width (SpectrogramLayer) and height (SpectrumLayer) for layout purposes. A get method should be added to obtain the scale size parameter outside the layer class.
author mathieub <mathieu.barthet@eecs.qmul.ac.uk>
date Wed, 06 Jul 2011 18:05:42 +0100
parents 369a197737c7
children
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@349 27 #include <QMutex>
Chris@133 28
Chris@133 29 class FFTModel;
Chris@133 30
Chris@193 31 class SpectrumLayer : public SliceLayer
Chris@133 32 {
Chris@133 33 Q_OBJECT
Chris@133 34
Chris@133 35 public:
Chris@133 36 SpectrumLayer();
Chris@133 37 ~SpectrumLayer();
Chris@133 38
Chris@133 39 void setModel(DenseTimeValueModel *model);
Chris@193 40 virtual const Model *getModel() const { return m_originModel; }
Chris@133 41
Chris@254 42 virtual bool getCrosshairExtents(View *, QPainter &, QPoint cursorPos,
Chris@254 43 std::vector<QRect> &extents) const;
Chris@254 44 virtual void paintCrosshairs(View *, QPainter &, QPoint) const;
Chris@254 45
Chris@199 46 virtual QString getFeatureDescription(View *v, QPoint &) const;
Chris@199 47
mathieu@592 48 //virtual int getHorizontalScaleHeight(View *, QPainter &) const;
mathieu@592 49
Chris@275 50 virtual void paint(View *v, QPainter &paint, QRect rect) const;
Chris@275 51
Chris@277 52 virtual VerticalPosition getPreferredFrameCountPosition() const {
Chris@277 53 return PositionTop;
Chris@277 54 }
Chris@277 55
Chris@153 56 virtual PropertyList getProperties() const;
Chris@153 57 virtual QString getPropertyLabel(const PropertyName &) const;
Chris@335 58 virtual QString getPropertyIconName(const PropertyName &) const;
Chris@153 59 virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@153 60 virtual QString getPropertyGroupName(const PropertyName &) const;
Chris@153 61 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@216 62 int *min, int *max, int *deflt) const;
Chris@153 63 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@153 64 int value) const;
Chris@167 65 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
Chris@153 66 virtual void setProperty(const PropertyName &, int value);
Chris@133 67 virtual void setProperties(const QXmlAttributes &);
Chris@133 68
Chris@133 69 virtual bool getValueExtents(float &min, float &max,
Chris@133 70 bool &logarithmic, QString &unit) const;
Chris@133 71
Chris@267 72 virtual bool getXScaleValue(const View *v, int x,
Chris@260 73 float &value, QString &unit) const;
Chris@260 74
Chris@274 75 virtual bool getYScaleValue(const View *, int y,
Chris@274 76 float &value, QString &unit) const;
Chris@274 77
Chris@274 78 virtual bool getYScaleDifference(const View *, int y0, int y1,
Chris@274 79 float &diff, QString &unit) const;
Chris@274 80
Chris@248 81 virtual bool isLayerScrollable(const View *) const { return false; }
Chris@133 82
Chris@153 83 void setChannel(int);
Chris@153 84 int getChannel() const { return m_channel; }
Chris@153 85
Chris@153 86 void setWindowSize(size_t);
Chris@153 87 size_t getWindowSize() const { return m_windowSize; }
Chris@153 88
Chris@153 89 void setWindowHopLevel(size_t level);
Chris@153 90 size_t getWindowHopLevel() const { return m_windowHopLevel; }
Chris@153 91
Chris@153 92 void setWindowType(WindowType type);
Chris@153 93 WindowType getWindowType() const { return m_windowType; }
Chris@153 94
Chris@284 95 void setShowPeaks(bool);
Chris@284 96 bool getShowPeaks() const { return m_showPeaks; }
Chris@284 97
Chris@316 98 virtual void toXml(QTextStream &stream, QString indent = "",
Chris@316 99 QString extraAttributes = "") const;
Chris@153 100
mathieu@592 101 virtual bool scaleClicked(const View *, QMouseEvent *);
mathieu@592 102
Chris@153 103 protected slots:
Chris@153 104 void preferenceChanged(PropertyContainer::PropertyName name);
Chris@133 105
Chris@133 106 protected:
Chris@193 107 // make this SliceLayer method unavailable to the general public
Chris@193 108 // virtual void setModel(DenseThreeDimensionalModel *model) {
Chris@193 109 // SliceLayer::setModel(model);
Chris@193 110 // }
Chris@193 111
Chris@193 112 DenseTimeValueModel *m_originModel;
Chris@153 113 int m_channel;
Chris@153 114 bool m_channelSet;
Chris@153 115 size_t m_windowSize;
Chris@153 116 WindowType m_windowType;
Chris@153 117 size_t m_windowHopLevel;
Chris@284 118 bool m_showPeaks;
Chris@275 119 mutable bool m_newFFTNeeded;
Chris@153 120
Chris@349 121 mutable QMutex m_fftMutex;
Chris@349 122
Chris@193 123 void setupFFT();
Chris@153 124
Chris@254 125 virtual void getBiasCurve(BiasCurve &) const;
Chris@254 126 BiasCurve m_biasCurve;
Chris@254 127
Chris@265 128 virtual float getXForBin(int bin, int totalBins, float w) const;
Chris@265 129 virtual int getBinForX(float x, int totalBins, float w) const;
Chris@265 130
Chris@254 131 float getFrequencyForX(float x, float w) const;
Chris@254 132 float getXForFrequency(float freq, float w) const;
Chris@254 133
Chris@153 134 size_t getWindowIncrement() const {
Chris@153 135 if (m_windowHopLevel == 0) return m_windowSize;
Chris@153 136 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4;
Chris@153 137 else return m_windowSize / (1 << (m_windowHopLevel - 1));
Chris@153 138 }
Chris@133 139 };
Chris@133 140
Chris@133 141 #endif