Mercurial > hg > svgui
comparison layer/SpectrogramLayer.h @ 114:991de8783cf5
* Add fuzzy-adapter class to pick out subset data from FFT data server, instead
of having separate methods in data server class. Update spectrogram to use it.
* Give spectrogram layer one fft adapter per view, in case the views need
different zero-padding levels.
* Reduce ridiculous memory consumption of MatrixFile for tall matrices.
Still very much work in progress here.
author | Chris Cannam |
---|---|
date | Fri, 30 Jun 2006 11:26:10 +0000 |
parents | 7a23edd831cb |
children | 47cb32bb35ab |
comparison
equal
deleted
inserted
replaced
113:7a23edd831cb | 114:991de8783cf5 |
---|---|
20 #include "base/Window.h" | 20 #include "base/Window.h" |
21 #include "base/RealTime.h" | 21 #include "base/RealTime.h" |
22 #include "base/Thread.h" | 22 #include "base/Thread.h" |
23 #include "model/PowerOfSqrtTwoZoomConstraint.h" | 23 #include "model/PowerOfSqrtTwoZoomConstraint.h" |
24 #include "model/DenseTimeValueModel.h" | 24 #include "model/DenseTimeValueModel.h" |
25 #include "fileio/FFTDataServer.h" | 25 |
26 #include "fileio/FFTFuzzyAdapter.h" | |
26 | 27 |
27 #include <QMutex> | 28 #include <QMutex> |
28 #include <QWaitCondition> | 29 #include <QWaitCondition> |
29 #include <QImage> | 30 #include <QImage> |
30 #include <QPixmap> | 31 #include <QPixmap> |
32 class View; | 33 class View; |
33 class QPainter; | 34 class QPainter; |
34 class QImage; | 35 class QImage; |
35 class QPixmap; | 36 class QPixmap; |
36 class QTimer; | 37 class QTimer; |
38 class FFTFuzzyAdapter; | |
39 | |
37 | 40 |
38 /** | 41 /** |
39 * SpectrogramLayer represents waveform data (obtained from a | 42 * SpectrogramLayer represents waveform data (obtained from a |
40 * DenseTimeValueModel) in spectrogram form. | 43 * DenseTimeValueModel) in spectrogram form. |
41 */ | 44 */ |
243 QColor m_colours[256]; | 246 QColor m_colours[256]; |
244 }; | 247 }; |
245 | 248 |
246 ColourMap m_colourMap; | 249 ColourMap m_colourMap; |
247 | 250 |
248 FFTDataServer *m_fftServer; | |
249 void getFFTServer(); | |
250 | |
251 struct PixmapCache | 251 struct PixmapCache |
252 { | 252 { |
253 QPixmap pixmap; | 253 QPixmap pixmap; |
254 QRect validArea; | 254 QRect validArea; |
255 long startFrame; | 255 long startFrame; |
259 void invalidatePixmapCaches(); | 259 void invalidatePixmapCaches(); |
260 void invalidatePixmapCaches(size_t startFrame, size_t endFrame); | 260 void invalidatePixmapCaches(size_t startFrame, size_t endFrame); |
261 mutable ViewPixmapCache m_pixmapCaches; | 261 mutable ViewPixmapCache m_pixmapCaches; |
262 mutable QImage m_drawBuffer; | 262 mutable QImage m_drawBuffer; |
263 | 263 |
264 QTimer *m_updateTimer; | 264 mutable QTimer *m_updateTimer; |
265 | 265 |
266 mutable size_t m_candidateFillStartFrame; | 266 mutable size_t m_candidateFillStartFrame; |
267 size_t m_lastFillExtent; | 267 mutable size_t m_lastFillExtent; |
268 bool m_exiting; | 268 bool m_exiting; |
269 | 269 |
270 void setColourmap(); | 270 void setColourmap(); |
271 void rotateColourmap(int distance); | 271 void rotateColourmap(int distance); |
272 | 272 |
307 if (m_windowHopLevel == 0) return m_windowSize; | 307 if (m_windowHopLevel == 0) return m_windowSize; |
308 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4; | 308 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4; |
309 else return m_windowSize / (1 << (m_windowHopLevel - 1)); | 309 else return m_windowSize / (1 << (m_windowHopLevel - 1)); |
310 } | 310 } |
311 | 311 |
312 size_t getFFTWidth() const { | 312 size_t getZeroPadLevel(const View *v) const; |
313 return m_fftServer->getWidth(getWindowIncrement(), m_fftSize); | 313 size_t getFFTSize(const View *v) const; |
314 } | 314 FFTFuzzyAdapter *getFFTAdapter(const View *v) const; |
315 size_t getFFTHeight() const { | 315 void invalidateFFTAdapters(); |
316 return m_fftServer->getHeight(getWindowIncrement(), m_fftSize); | 316 typedef std::map<const View *, FFTFuzzyAdapter *> ViewFFTMap; |
317 } | 317 mutable ViewFFTMap m_fftAdapters; |
318 float getFFTMagnitudeAt(size_t x, size_t y) const { | |
319 return m_fftServer->getMagnitudeAt(getWindowIncrement(), m_fftSize, | |
320 x, y); | |
321 } | |
322 float getFFTNormalizedMagnitudeAt(size_t x, size_t y) const { | |
323 return m_fftServer->getNormalizedMagnitudeAt(getWindowIncrement(), m_fftSize, | |
324 x, y); | |
325 } | |
326 float getFFTPhaseAt(size_t x, size_t y) const { | |
327 return m_fftServer->getPhaseAt(getWindowIncrement(), m_fftSize, | |
328 x, y); | |
329 } | |
330 void getFFTValuesAt(size_t x, size_t y, float &real, float &imag) const { | |
331 m_fftServer->getValuesAt(getWindowIncrement(), m_fftSize, | |
332 x, y, real, imag); | |
333 } | |
334 bool isFFTLocalPeak(size_t x, size_t y) const { | |
335 return m_fftServer->isLocalPeak(getWindowIncrement(), m_fftSize, | |
336 x, y); | |
337 } | |
338 bool isFFTOverThreshold(size_t x, size_t y, float threshold) const { | |
339 return m_fftServer->isOverThreshold(getWindowIncrement(), m_fftSize, | |
340 x, y, threshold); | |
341 } | |
342 bool isFFTColumnReady(size_t x) const { | |
343 return m_fftServer->isColumnReady(getWindowIncrement(), m_fftSize, x); | |
344 } | |
345 }; | 318 }; |
346 | 319 |
347 #endif | 320 #endif |