Mercurial > hg > svgui
comparison layer/SpectrogramLayer.h @ 39:5ce844ec854a
* Fix to phase cacheing
author | Chris Cannam |
---|---|
date | Thu, 23 Feb 2006 18:06:31 +0000 |
parents | beb801473743 |
children | 3be4438b186d |
comparison
equal
deleted
inserted
replaced
38:beb801473743 | 39:5ce844ec854a |
---|---|
242 float getNormalizedMagnitudeAt(size_t x, size_t y) const { | 242 float getNormalizedMagnitudeAt(size_t x, size_t y) const { |
243 return float(m_magnitude[y][x]) / 65535.0; | 243 return float(m_magnitude[y][x]) / 65535.0; |
244 } | 244 } |
245 | 245 |
246 float getPhaseAt(size_t x, size_t y) const { | 246 float getPhaseAt(size_t x, size_t y) const { |
247 return (float(m_phase[y][x]) / 32767.0) * M_PI; | 247 int16_t i = (int16_t)m_phase[y][x]; |
248 return (float(i) / 32767.0) * M_PI; | |
248 } | 249 } |
249 | 250 |
250 bool isLocalPeak(size_t x, size_t y) const { | 251 bool isLocalPeak(size_t x, size_t y) const { |
251 if (y > 0 && m_magnitude[y][x] < m_magnitude[y-1][x]) return false; | 252 if (y > 0 && m_magnitude[y][x] < m_magnitude[y-1][x]) return false; |
252 if (y < m_height-1 && m_magnitude[y][x] < m_magnitude[y+1][x]) return false; | 253 if (y < m_height-1 && m_magnitude[y][x] < m_magnitude[y+1][x]) return false; |
271 m_magnitude[y][x] = uint16_t(norm * 65535.0); | 272 m_magnitude[y][x] = uint16_t(norm * 65535.0); |
272 } | 273 } |
273 | 274 |
274 void setPhaseAt(size_t x, size_t y, float phase) { | 275 void setPhaseAt(size_t x, size_t y, float phase) { |
275 // phase in range -pi -> pi | 276 // phase in range -pi -> pi |
276 m_phase[y][x] = uint16_t((phase * 32767) / M_PI); | 277 m_phase[y][x] = uint16_t(int16_t((phase * 32767) / M_PI)); |
277 } | 278 } |
278 | 279 |
279 QColor getColour(unsigned char index) const { | 280 QColor getColour(unsigned char index) const { |
280 return m_colours[index]; | 281 return m_colours[index]; |
281 } | 282 } |