Mercurial > hg > svgui
changeset 115:47cb32bb35ab
* Restore progress updates to spectrogram
author | Chris Cannam |
---|---|
date | Wed, 05 Jul 2006 16:15:22 +0000 |
parents | 991de8783cf5 |
children | 4a6e6aedf632 |
files | layer/Colour3DPlotLayer.h layer/NoteLayer.h layer/SpectrogramLayer.cpp layer/SpectrogramLayer.h layer/TextLayer.h layer/TimeInstantLayer.h layer/WaveformLayer.cpp layer/WaveformLayer.h |
diffstat | 8 files changed, 85 insertions(+), 93 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.h Fri Jun 30 11:26:10 2006 +0000 +++ b/layer/Colour3DPlotLayer.h Wed Jul 05 16:15:22 2006 +0000 @@ -62,7 +62,7 @@ void setModel(const DenseThreeDimensionalModel *model); - virtual int getCompletion() const { return m_model->getCompletion(); } + virtual int getCompletion(View *) const { return m_model->getCompletion(); } virtual bool getValueExtents(float &, float &, bool &, QString &) const { return false; }
--- a/layer/NoteLayer.h Fri Jun 30 11:26:10 2006 +0000 +++ b/layer/NoteLayer.h Wed Jul 05 16:15:22 2006 +0000 @@ -86,7 +86,7 @@ virtual bool isLayerEditable() const { return true; } - virtual int getCompletion() const { return m_model->getCompletion(); } + virtual int getCompletion(View *) const { return m_model->getCompletion(); } virtual bool getValueExtents(float &min, float &max, bool &log, QString &unit) const;
--- a/layer/SpectrogramLayer.cpp Fri Jun 30 11:26:10 2006 +0000 +++ b/layer/SpectrogramLayer.cpp Wed Jul 05 16:15:22 2006 +0000 @@ -34,7 +34,7 @@ #include <cassert> #include <cmath> -//#define DEBUG_SPECTROGRAM_REPAINT 1 +#define DEBUG_SPECTROGRAM_REPAINT 1 SpectrogramLayer::SpectrogramLayer(Configuration config) : Layer(), @@ -57,7 +57,6 @@ m_normalizeColumns(false), m_updateTimer(0), m_candidateFillStartFrame(0), - m_lastFillExtent(0), m_exiting(false) { if (config == MelodicRange) { @@ -114,38 +113,7 @@ emit modelReplaced(); } -/*!!! -void -SpectrogramLayer::invalidateFFTAdapters() -{ -// if (m_fftServer) { -// FFTDataServer::releaseInstance(m_fftServer); -// m_fftServer = 0; -// } - - delete m_fftServer; - m_fftServer = 0; - - if (m_model) { -// m_fftServer = FFTDataServer::getFuzzyInstance(m_model, - m_fftServer = new FFTFuzzyAdapter(m_model, - m_channel, - m_windowType, - m_windowSize, - getWindowIncrement(), - m_fftSize, - true, - m_candidateFillStartFrame); - - m_lastFillExtent = 0; - - delete m_updateTimer; - m_updateTimer = new QTimer(this); - connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(fillTimerTimedOut())); - m_updateTimer->start(200); - } -} -*/ + Layer::PropertyList SpectrogramLayer::getProperties() const { @@ -560,7 +528,7 @@ //!!! when are views removed from the map? on setLayerDormant? const View *v = i->first; - if (startFrame < v->getEndFrame() && endFrame >= v->getStartFrame()) { + if (startFrame < v->getEndFrame() && int(endFrame) >= v->getStartFrame()) { i->second.validArea = QRect(); } } @@ -861,7 +829,7 @@ m_pixmapCaches.erase(v); if (m_fftAdapters.find(v) != m_fftAdapters.end()) { - delete m_fftAdapters[v]; + delete m_fftAdapters[v].first; m_fftAdapters.erase(v); } @@ -887,43 +855,66 @@ void SpectrogramLayer::fillTimerTimedOut() { -/*!!! - if (m_fftServer && m_model) { - - size_t fillExtent = m_fftServer->getFillExtent(); + if (!m_model) return; + + bool allDone = true; + + for (ViewFFTMap::iterator i = m_fftAdapters.begin(); + i != m_fftAdapters.end(); ++i) { + + const View *v = i->first; + const FFTFuzzyAdapter *adapter = i->second.first; + size_t lastFill = i->second.second; + + if (adapter) { + + size_t fill = adapter->getFillExtent(); + #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::fillTimerTimedOut: extent " << fillExtent << ", last " << m_lastFillExtent << ", total " << m_model->getEndFrame() << std::endl; + std::cerr << "SpectrogramLayer::fillTimerTimedOut: extent for " << adapter << ": " << fill << ", last " << lastFill << ", total " << m_model->getEndFrame() << std::endl; #endif - if (fillExtent >= m_lastFillExtent) { - if (fillExtent >= m_model->getEndFrame() && m_lastFillExtent > 0) { + + if (fill >= lastFill) { + if (fill >= m_model->getEndFrame() && lastFill > 0) { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "complete!" << std::endl; + std::cerr << "complete!" << std::endl; #endif - invalidatePixmapCaches(); - emit modelChanged(); - delete m_updateTimer; - m_updateTimer = 0; - m_lastFillExtent = 0; - } else if (fillExtent > m_lastFillExtent) { + invalidatePixmapCaches(); + emit modelChanged(); + i->second.second = -1; + + } else if (fill > lastFill) { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer: emitting modelChanged(" - << m_lastFillExtent << "," << fillExtent << ")" << std::endl; + std::cerr << "SpectrogramLayer: emitting modelChanged(" + << lastFill << "," << fill << ")" << std::endl; #endif - invalidatePixmapCaches(m_lastFillExtent, fillExtent); - emit modelChanged(m_lastFillExtent, fillExtent); - m_lastFillExtent = fillExtent; - } - } else { + invalidatePixmapCaches(lastFill, fill); + emit modelChanged(lastFill, fill); + i->second.second = fill; + } + } else { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer: going backwards, emitting modelChanged(" - << m_model->getStartFrame() << "," << m_model->getEndFrame() << ")" << std::endl; + std::cerr << "SpectrogramLayer: going backwards, emitting modelChanged(" + << m_model->getStartFrame() << "," << m_model->getEndFrame() << ")" << std::endl; #endif - invalidatePixmapCaches(); - emit modelChanged(m_model->getStartFrame(), m_model->getEndFrame()); - m_lastFillExtent = fillExtent; - } + invalidatePixmapCaches(); + emit modelChanged(m_model->getStartFrame(), m_model->getEndFrame()); + i->second.second = fill; + } + + if (i->second.second >= 0) { + allDone = false; + } + } } -*/ + + if (allDone) { +#ifdef DEBUG_SPECTROGRAM_REPAINT + std::cerr << "SpectrogramLayer: all complete!" << std::endl; +#endif + delete m_updateTimer; + m_updateTimer = 0; + } } void @@ -1433,22 +1424,23 @@ size_t fftSize = getFFTSize(v); if (m_fftAdapters.find(v) != m_fftAdapters.end()) { - if (m_fftAdapters[v]->getHeight() != fftSize / 2) { - delete m_fftAdapters[v]; + if (m_fftAdapters[v].first->getHeight() != fftSize / 2) { + delete m_fftAdapters[v].first; m_fftAdapters.erase(v); } } if (m_fftAdapters.find(v) == m_fftAdapters.end()) { - m_fftAdapters[v] = new FFTFuzzyAdapter(m_model, - m_channel, - m_windowType, - m_windowSize, - getWindowIncrement(), - getFFTSize(v), - true, - m_candidateFillStartFrame); - m_lastFillExtent = 0; + m_fftAdapters[v] = FFTFillPair + (new FFTFuzzyAdapter(m_model, + m_channel, + m_windowType, + m_windowSize, + getWindowIncrement(), + getFFTSize(v), + true, + m_candidateFillStartFrame), + 0); delete m_updateTimer; m_updateTimer = new QTimer((SpectrogramLayer *)this); @@ -1457,7 +1449,7 @@ m_updateTimer->start(200); } - return m_fftAdapters[v]; + return m_fftAdapters[v].first; } void @@ -1465,7 +1457,7 @@ { for (ViewFFTMap::iterator i = m_fftAdapters.begin(); i != m_fftAdapters.end(); ++i) { - delete i->second; + delete i->second.first; } m_fftAdapters.clear(); @@ -1914,15 +1906,14 @@ } int -SpectrogramLayer::getCompletion() const +SpectrogramLayer::getCompletion(View *v) const { -/*!!! - if (m_updateTimer == 0 || !m_fftServer) return 100; - size_t completion = m_fftServer->getFillCompletion(); -// std::cerr << "SpectrogramLayer::getCompletion: completion = " << completion << std::endl; + if (m_updateTimer == 0) return 100; + if (m_fftAdapters.find(v) == m_fftAdapters.end()) return 100; + + size_t completion = m_fftAdapters[v].first->getFillCompletion(); + std::cerr << "SpectrogramLayer::getCompletion: completion = " << completion << std::endl; return completion; -*/ - return 100; } bool
--- a/layer/SpectrogramLayer.h Fri Jun 30 11:26:10 2006 +0000 +++ b/layer/SpectrogramLayer.h Wed Jul 05 16:15:22 2006 +0000 @@ -186,7 +186,7 @@ float getYForFrequency(View *v, float frequency) const; float getFrequencyForY(View *v, int y) const; - virtual int getCompletion() const; + virtual int getCompletion(View *v) const; virtual bool getValueExtents(float &min, float &max, bool &logarithmic, QString &unit) const; @@ -264,7 +264,6 @@ mutable QTimer *m_updateTimer; mutable size_t m_candidateFillStartFrame; - mutable size_t m_lastFillExtent; bool m_exiting; void setColourmap(); @@ -313,7 +312,9 @@ size_t getFFTSize(const View *v) const; FFTFuzzyAdapter *getFFTAdapter(const View *v) const; void invalidateFFTAdapters(); - typedef std::map<const View *, FFTFuzzyAdapter *> ViewFFTMap; + + typedef std::pair<FFTFuzzyAdapter *, int> FFTFillPair; // adapter, last fill + typedef std::map<const View *, FFTFillPair> ViewFFTMap; mutable ViewFFTMap m_fftAdapters; };
--- a/layer/TextLayer.h Fri Jun 30 11:26:10 2006 +0000 +++ b/layer/TextLayer.h Wed Jul 05 16:15:22 2006 +0000 @@ -76,7 +76,7 @@ virtual bool isLayerEditable() const { return true; } - virtual int getCompletion() const { return m_model->getCompletion(); } + virtual int getCompletion(View *) const { return m_model->getCompletion(); } virtual bool getValueExtents(float &min, float &max, bool &logarithmic, QString &unit) const;
--- a/layer/TimeInstantLayer.h Fri Jun 30 11:26:10 2006 +0000 +++ b/layer/TimeInstantLayer.h Wed Jul 05 16:15:22 2006 +0000 @@ -84,7 +84,7 @@ virtual bool isLayerEditable() const { return true; } - virtual int getCompletion() const { return m_model->getCompletion(); } + virtual int getCompletion(View *) const { return m_model->getCompletion(); } virtual bool needsTextLabelHeight() const { return m_model->hasTextLabels(); }
--- a/layer/WaveformLayer.cpp Fri Jun 30 11:26:10 2006 +0000 +++ b/layer/WaveformLayer.cpp Wed Jul 05 16:15:22 2006 +0000 @@ -339,7 +339,7 @@ } int -WaveformLayer::getCompletion() const +WaveformLayer::getCompletion(View *) const { int completion = 100; if (!m_model || !m_model->isOK()) return completion;
--- a/layer/WaveformLayer.h Fri Jun 30 11:26:10 2006 +0000 +++ b/layer/WaveformLayer.h Wed Jul 05 16:15:22 2006 +0000 @@ -171,7 +171,7 @@ virtual bool isLayerScrollable(const View *) const; - virtual int getCompletion() const; + virtual int getCompletion(View *) const; virtual bool getValueExtents(float &min, float &max, bool &log, QString &unit) const;