annotate layer/SpectrumLayer.h @ 277:8acd30ed735c

* Fix up and simplify the LayerTreeModel, removing a horrible memory leak * Move phase-unwrapped frequency estimation from SpectrogramLayer to FFTDataServer * Make the spectrum show peak phase-unwrapped frequencies as well (still needs work) * Start adding piano keyboard horizontal scale to spectrum * Debug output for id3 tags
author Chris Cannam
date Tue, 03 Jul 2007 12:46:18 +0000
parents bbe57afe9d7d
children 1284955856ab
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@133 27
Chris@133 28 class FFTModel;
Chris@133 29
Chris@193 30 class SpectrumLayer : public SliceLayer
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@193 39 virtual const Model *getModel() const { return m_originModel; }
Chris@133 40
Chris@254 41 virtual bool getCrosshairExtents(View *, QPainter &, QPoint cursorPos,
Chris@254 42 std::vector<QRect> &extents) const;
Chris@254 43 virtual void paintCrosshairs(View *, QPainter &, QPoint) const;
Chris@254 44
Chris@199 45 virtual QString getFeatureDescription(View *v, QPoint &) const;
Chris@199 46
Chris@275 47 virtual void paint(View *v, QPainter &paint, QRect rect) const;
Chris@275 48
Chris@277 49 virtual VerticalPosition getPreferredFrameCountPosition() const {
Chris@277 50 return PositionTop;
Chris@277 51 }
Chris@277 52
Chris@153 53 virtual PropertyList getProperties() const;
Chris@153 54 virtual QString getPropertyLabel(const PropertyName &) const;
Chris@153 55 virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@153 56 virtual QString getPropertyGroupName(const PropertyName &) const;
Chris@153 57 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@216 58 int *min, int *max, int *deflt) const;
Chris@153 59 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@153 60 int value) const;
Chris@167 61 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
Chris@153 62 virtual void setProperty(const PropertyName &, int value);
Chris@133 63 virtual void setProperties(const QXmlAttributes &);
Chris@133 64
Chris@133 65 virtual bool getValueExtents(float &min, float &max,
Chris@133 66 bool &logarithmic, QString &unit) const;
Chris@133 67
Chris@267 68 virtual bool getXScaleValue(const View *v, int x,
Chris@260 69 float &value, QString &unit) const;
Chris@260 70
Chris@274 71 virtual bool getYScaleValue(const View *, int y,
Chris@274 72 float &value, QString &unit) const;
Chris@274 73
Chris@274 74 virtual bool getYScaleDifference(const View *, int y0, int y1,
Chris@274 75 float &diff, QString &unit) const;
Chris@274 76
Chris@248 77 virtual bool isLayerScrollable(const View *) const { return false; }
Chris@133 78
Chris@153 79 void setChannel(int);
Chris@153 80 int getChannel() const { return m_channel; }
Chris@153 81
Chris@153 82 void setWindowSize(size_t);
Chris@153 83 size_t getWindowSize() const { return m_windowSize; }
Chris@153 84
Chris@153 85 void setWindowHopLevel(size_t level);
Chris@153 86 size_t getWindowHopLevel() const { return m_windowHopLevel; }
Chris@153 87
Chris@153 88 void setWindowType(WindowType type);
Chris@153 89 WindowType getWindowType() const { return m_windowType; }
Chris@153 90
Chris@153 91 virtual QString toXmlString(QString indent = "",
Chris@153 92 QString extraAttributes = "") const;
Chris@153 93
Chris@153 94 protected slots:
Chris@153 95 void preferenceChanged(PropertyContainer::PropertyName name);
Chris@133 96
Chris@133 97 protected:
Chris@193 98 // make this SliceLayer method unavailable to the general public
Chris@193 99 // virtual void setModel(DenseThreeDimensionalModel *model) {
Chris@193 100 // SliceLayer::setModel(model);
Chris@193 101 // }
Chris@193 102
Chris@193 103 DenseTimeValueModel *m_originModel;
Chris@153 104 int m_channel;
Chris@153 105 bool m_channelSet;
Chris@153 106 size_t m_windowSize;
Chris@153 107 WindowType m_windowType;
Chris@153 108 size_t m_windowHopLevel;
Chris@275 109 mutable bool m_newFFTNeeded;
Chris@153 110
Chris@193 111 void setupFFT();
Chris@153 112
Chris@254 113 virtual void getBiasCurve(BiasCurve &) const;
Chris@254 114 BiasCurve m_biasCurve;
Chris@254 115
Chris@265 116 virtual float getXForBin(int bin, int totalBins, float w) const;
Chris@265 117 virtual int getBinForX(float x, int totalBins, float w) const;
Chris@265 118
Chris@254 119 float getFrequencyForX(float x, float w) const;
Chris@254 120 float getXForFrequency(float freq, float w) const;
Chris@254 121
Chris@153 122 size_t getWindowIncrement() const {
Chris@153 123 if (m_windowHopLevel == 0) return m_windowSize;
Chris@153 124 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4;
Chris@153 125 else return m_windowSize / (1 << (m_windowHopLevel - 1));
Chris@153 126 }
Chris@133 127 };
Chris@133 128
Chris@133 129 #endif