comparison layer/SpectrogramLayer.h @ 35:10ba9276a315

* Add TextModel and TextLayer types * Make View refresh work better when editing a model (previously edits might not be refreshed if their visible changed area extended beyond the strict frame range that was being modified in the model) * Add phase-adjusted instantaneous frequency display to spectrogram layer (still a work in progress) * Pull maths aliases out into a separate header in dsp/maths so MathUtilities can be included without introducing them
author Chris Cannam
date Mon, 20 Feb 2006 13:33:36 +0000
parents 651e4e868bcc
children c28ebb4ba4de
comparison
equal deleted inserted replaced
34:c43f2c4f66f2 35:10ba9276a315
105 * details of meter and dB scaling. The default is dBColourScale. 105 * details of meter and dB scaling. The default is dBColourScale.
106 */ 106 */
107 void setColourScale(ColourScale); 107 void setColourScale(ColourScale);
108 ColourScale getColourScale() const; 108 ColourScale getColourScale() const;
109 109
110 enum FrequencyScale { LinearFrequencyScale, LogFrequencyScale }; 110 enum FrequencyScale {
111 LinearFrequencyScale,
112 LogFrequencyScale
113 };
111 114
112 /** 115 /**
113 * Specify the scale for the y axis. 116 * Specify the scale for the y axis.
114 */ 117 */
115 void setFrequencyScale(FrequencyScale); 118 void setFrequencyScale(FrequencyScale);
116 FrequencyScale getFrequencyScale() const; 119 FrequencyScale getFrequencyScale() const;
120
121 enum FrequencyAdjustment {
122 RawFrequency,
123 PhaseAdjustedFrequency,
124 PhaseAdjustedPeaks
125 };
126
127 /**
128 * Specify the processing of frequency bins for the y axis.
129 */
130 void setFrequencyAdjustment(FrequencyAdjustment);
131 FrequencyAdjustment getFrequencyAdjustment() const;
117 132
118 enum ColourScheme { DefaultColours, WhiteOnBlack, BlackOnWhite, 133 enum ColourScheme { DefaultColours, WhiteOnBlack, BlackOnWhite,
119 RedOnBlue, YellowOnBlack, RedOnBlack }; 134 RedOnBlue, YellowOnBlack, RedOnBlack };
120 135
121 void setColourScheme(ColourScheme scheme); 136 void setColourScheme(ColourScheme scheme);
149 void fillTimerTimedOut(); 164 void fillTimerTimedOut();
150 165
151 protected: 166 protected:
152 const DenseTimeValueModel *m_model; // I do not own this 167 const DenseTimeValueModel *m_model; // I do not own this
153 168
154 int m_channel; 169 int m_channel;
155 size_t m_windowSize; 170 size_t m_windowSize;
156 WindowType m_windowType; 171 WindowType m_windowType;
157 size_t m_windowOverlap; 172 size_t m_windowOverlap;
158 float m_gain; 173 float m_gain;
159 int m_colourRotation; 174 int m_colourRotation;
160 size_t m_maxFrequency; 175 size_t m_maxFrequency;
161 ColourScale m_colourScale; 176 ColourScale m_colourScale;
162 ColourScheme m_colourScheme; 177 ColourScheme m_colourScheme;
163 FrequencyScale m_frequencyScale; 178 FrequencyScale m_frequencyScale;
179 FrequencyAdjustment m_frequencyAdjustment;
164 180
165 // A QImage would do just as well here, and we originally used 181 // A QImage would do just as well here, and we originally used
166 // one: the problem is that we want to munlock() the memory it 182 // one: the problem is that we want to munlock() the memory it
167 // uses, and it's much easier to do that if we control it. This 183 // uses, and it's much easier to do that if we control it. This
168 // cache is hardwired to an effective 8-bit colour mapped layout. 184 // cache is hardwired to an effective 8-bit colour mapped layout.
171 Cache(size_t width, size_t height); 187 Cache(size_t width, size_t height);
172 ~Cache(); 188 ~Cache();
173 189
174 size_t getWidth() const; 190 size_t getWidth() const;
175 size_t getHeight() const; 191 size_t getHeight() const;
192
193 void resize(size_t width, size_t height);
176 194
177 unsigned char getValueAt(size_t x, size_t y) const; 195 unsigned char getValueAt(size_t x, size_t y) const;
178 void setValueAt(size_t x, size_t y, unsigned char value); 196 void setValueAt(size_t x, size_t y, unsigned char value);
179 197
180 QColor getColour(unsigned char index) const; 198 QColor getColour(unsigned char index) const;
188 unsigned char *m_values; 206 unsigned char *m_values;
189 QColor m_colours[256]; 207 QColor m_colours[256];
190 }; 208 };
191 209
192 Cache *m_cache; 210 Cache *m_cache;
211 Cache *m_phaseAdjustCache;
193 bool m_cacheInvalid; 212 bool m_cacheInvalid;
194 213
195 class CacheFillThread : public QThread 214 class CacheFillThread : public QThread
196 { 215 {
197 public: 216 public:
232 fftw_complex *outputBuffer, 251 fftw_complex *outputBuffer,
233 fftw_plan plan, 252 fftw_plan plan,
234 size_t windowSize, 253 size_t windowSize,
235 size_t windowIncrement, 254 size_t windowIncrement,
236 const Window<double> &windower, 255 const Window<double> &windower,
237 bool lock) 256 bool resetStoredPhase)
238 const; 257 const;
239 258
240 bool getYBinRange(int y, float &freqBinMin, float &freqBinMax) const; 259 bool getYBinRange(int y, float &freqBinMin, float &freqBinMax) const;
241 260
242 struct LayerRange { 261 struct LayerRange {
246 size_t modelEnd; 265 size_t modelEnd;
247 }; 266 };
248 bool getXBinRange(int x, float &windowMin, float &windowMax) const; 267 bool getXBinRange(int x, float &windowMin, float &windowMax) const;
249 268
250 bool getYBinSourceRange(int y, float &freqMin, float &freqMax) const; 269 bool getYBinSourceRange(int y, float &freqMin, float &freqMax) const;
270 bool getAdjustedYBinSourceRange(int x, int y,
271 float &freqMin, float &freqMax,
272 float &adjFreqMin, float &adjFreqMax) const;
251 bool getXBinSourceRange(int x, RealTime &timeMin, RealTime &timeMax) const; 273 bool getXBinSourceRange(int x, RealTime &timeMin, RealTime &timeMax) const;
252 bool getXYBinSourceRange(int x, int y, float &dbMin, float &dbMax) const; 274 bool getXYBinSourceRange(int x, int y, float &dbMin, float &dbMax) const;
253 275
254 size_t getWindowIncrement() const { 276 size_t getWindowIncrement() const {
255 return m_windowSize - m_windowSize * m_windowOverlap / 100; 277 return m_windowSize - m_windowSize * m_windowOverlap / 100;