comparison layer/SpectrogramLayer.h @ 41:f2c416cbdaa9

* Add time/Hz description for waveform model to the bottom right of a pane containing a waveform (also tried this in the status bar, wasn't so good) * Further spectrogram fixes
author Chris Cannam
date Fri, 24 Feb 2006 17:26:11 +0000
parents 3be4438b186d
children 1bdf285c4eac
comparison
equal deleted inserted replaced
40:3be4438b186d 41:f2c416cbdaa9
258 if (threshold == 0.0) return true; 258 if (threshold == 0.0) return true;
259 return getMagnitudeAt(x, y) > threshold; 259 return getMagnitudeAt(x, y) > threshold;
260 } 260 }
261 261
262 void setNormalizationFactor(size_t x, float factor) { 262 void setNormalizationFactor(size_t x, float factor) {
263 m_factor[x] = factor; 263 if (x < m_width) m_factor[x] = factor;
264 } 264 }
265 265
266 void setMagnitudeAt(size_t x, size_t y, float mag) { 266 void setMagnitudeAt(size_t x, size_t y, float mag) {
267 // norm factor must already be set 267 // norm factor must already be set
268 setNormalizedMagnitudeAt(x, y, mag / m_factor[x]); 268 setNormalizedMagnitudeAt(x, y, mag / m_factor[x]);
269 } 269 }
270 270
271 void setNormalizedMagnitudeAt(size_t x, size_t y, float norm) { 271 void setNormalizedMagnitudeAt(size_t x, size_t y, float norm) {
272 m_magnitude[y][x] = uint16_t(norm * 65535.0); 272 if (x < m_width && y < m_height) {
273 m_magnitude[y][x] = uint16_t(norm * 65535.0);
274 }
273 } 275 }
274 276
275 void setPhaseAt(size_t x, size_t y, float phase) { 277 void setPhaseAt(size_t x, size_t y, float phase) {
276 // phase in range -pi -> pi 278 // phase in range -pi -> pi
277 m_phase[y][x] = uint16_t(int16_t((phase * 32767) / M_PI)); 279 if (x < m_width && y < m_height) {
280 m_phase[y][x] = uint16_t(int16_t((phase * 32767) / M_PI));
281 }
278 } 282 }
279 283
280 QColor getColour(unsigned char index) const { 284 QColor getColour(unsigned char index) const {
281 return m_colours[index]; 285 return m_colours[index];
282 } 286 }