comparison data/model/FFTModel.h @ 275:522f82311e4e

* Pull peak-picker out of SpectrumLayer and into FFTModel; use combined peak-picker and frequency estimator for SpectrogramLayer (makes the peak frequency spectrogram a bit quicker) * Add more information to spectrum and spectrogram crosshairs
author Chris Cannam
date Wed, 04 Jul 2007 15:29:16 +0000
parents f1f47660483d
children daf89d31f45c
comparison
equal deleted inserted replaced
274:e412f65884ee 275:522f82311e4e
16 #ifndef _FFT_MODEL_H_ 16 #ifndef _FFT_MODEL_H_
17 #define _FFT_MODEL_H_ 17 #define _FFT_MODEL_H_
18 18
19 #include "data/fft/FFTDataServer.h" 19 #include "data/fft/FFTDataServer.h"
20 #include "DenseThreeDimensionalModel.h" 20 #include "DenseThreeDimensionalModel.h"
21
22 #include <set>
23 #include <map>
21 24
22 /** 25 /**
23 * An implementation of DenseThreeDimensionalModel that makes FFT data 26 * An implementation of DenseThreeDimensionalModel that makes FFT data
24 * derived from a DenseTimeValueModel available as a generic data grid. 27 * derived from a DenseTimeValueModel available as a generic data grid.
25 * The FFT data is acquired using FFTDataServer. 28 * The FFT data is acquired using FFTDataServer.
121 return 1.f; // Can't provide 124 return 1.f; // Can't provide
122 } 125 }
123 virtual void getColumn(size_t x, Column &result) const; 126 virtual void getColumn(size_t x, Column &result) const;
124 virtual QString getBinName(size_t n) const; 127 virtual QString getBinName(size_t n) const;
125 128
126 virtual bool estimateStableFrequency(size_t x, size_t y, float &frequency) { 129 /**
127 return m_server->estimateStableFrequency(x << m_xshift, y << m_yshift, 130 * Calculate an estimated frequency for a stable signal in this
128 getSampleRate(), frequency); 131 * bin, using phase unwrapping. This will be completely wrong if
129 } 132 * the signal is not stable here.
133 */
134 virtual bool estimateStableFrequency(size_t x, size_t y, float &frequency);
135
136 enum PeakPickType
137 {
138 AllPeaks, /// Any bin exceeding its immediate neighbours
139 MajorPeaks, /// Peaks picked using sliding median window
140 MajorPitchAdaptivePeaks /// Bigger window for higher frequencies
141 };
142
143 typedef std::set<size_t> PeakLocationSet;
144 typedef std::map<size_t, float> PeakSet;
145
146 /**
147 * Return locations of peak bins in the range [ymin,ymax]. If
148 * ymax is zero, getHeight()-1 will be used.
149 */
150 virtual PeakLocationSet getPeaks(PeakPickType type, size_t x,
151 size_t ymin = 0, size_t ymax = 0);
152
153 /**
154 * Return locations and estimated stable frequencies of peak bins.
155 */
156 virtual PeakSet getPeakFrequencies(PeakPickType type, size_t x,
157 size_t ymin = 0, size_t ymax = 0);
130 158
131 virtual int getCompletion() const { return m_server->getFillCompletion(); } 159 virtual int getCompletion() const { return m_server->getFillCompletion(); }
132 160
133 virtual Model *clone() const; 161 virtual Model *clone() const;
134 162
141 FFTModel &operator=(const FFTModel &); // not implemented 169 FFTModel &operator=(const FFTModel &); // not implemented
142 170
143 FFTDataServer *m_server; 171 FFTDataServer *m_server;
144 int m_xshift; 172 int m_xshift;
145 int m_yshift; 173 int m_yshift;
174
175 size_t getPeakPickWindowSize(PeakPickType type, size_t sampleRate, size_t bin) const;
146 }; 176 };
147 177
148 #endif 178 #endif