changeset 130:10eec0da9efe last-cc-copyright

* Move the current DenseThreeDimensionalModel to EditableDenseThreeDimensionalModel (wow!), and make DTDM an abstract base * Move FFTFuzzyAdapter to FFTModel as a new subclass of DTDM
author Chris Cannam
date Mon, 31 Jul 2006 17:05:18 +0000
parents 26d9d65e4941
children eaae73b6bd28
files layer/Colour3DPlotLayer.cpp layer/SpectrogramLayer.cpp layer/SpectrogramLayer.h
diffstat 3 files changed, 63 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp	Mon Jul 31 16:15:45 2006 +0000
+++ b/layer/Colour3DPlotLayer.cpp	Mon Jul 31 17:05:18 2006 +0000
@@ -90,11 +90,11 @@
     int y = pos.y();
 
     size_t modelStart = m_model->getStartFrame();
-    size_t modelWindow = m_model->getWindowSize();
+    size_t modelResolution = m_model->getResolution();
 
-    int sx0 = modelWindow *
-	int((v->getFrameForX(x) - long(modelStart)) / long(modelWindow));
-    int sx1 = sx0 + modelWindow;
+    int sx0 = modelResolution *
+	int((v->getFrameForX(x) - long(modelStart)) / long(modelResolution));
+    int sx1 = sx0 + modelResolution;
 
     float binHeight = float(v->height()) / m_model->getYBinCount();
     int sy = (v->height() - y) / binHeight;
@@ -198,9 +198,9 @@
 
     size_t modelStart = m_model->getStartFrame();
     size_t modelEnd = m_model->getEndFrame();
-    size_t modelWindow = m_model->getWindowSize();
+    size_t modelResolution = m_model->getResolution();
 
-    size_t cacheWidth = (modelEnd - modelStart) / modelWindow + 1;
+    size_t cacheWidth = (modelEnd - modelStart) / modelResolution + 1;
     size_t cacheHeight = m_model->getYBinCount();
 
     if (m_cache &&
@@ -231,7 +231,7 @@
 
 	m_cache->fill(min);
 
-	for (size_t f = modelStart; f <= modelEnd; f += modelWindow) {
+	for (size_t f = modelStart; f <= modelEnd; f += modelResolution) {
 	
 	    values.clear();
 	    m_model->getBinValues(f, values);
@@ -245,7 +245,7 @@
                 if (pixel < 0) pixel = 0;
 		if (pixel > 255) pixel = 255;
 
-		m_cache->setPixel(f / modelWindow, y, pixel);
+		m_cache->setPixel(f / modelResolution, y, pixel);
 	    }
 	}
     }
@@ -271,14 +271,14 @@
     //direction.  This one is only really appropriate for models with
     //far fewer bins in both directions.
 
-    int sx0 = int((v->getFrameForX(x0) - long(modelStart)) / long(modelWindow));
-    int sx1 = int((v->getFrameForX(x1) - long(modelStart)) / long(modelWindow));
+    int sx0 = int((v->getFrameForX(x0) - long(modelStart)) / long(modelResolution));
+    int sx1 = int((v->getFrameForX(x1) - long(modelStart)) / long(modelResolution));
     int sw = sx1 - sx0;
     int sh = m_model->getYBinCount();
 
 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT
     std::cerr << "Colour3DPlotLayer::paint: w " << w << ", h " << h << ", sx0 " << sx0 << ", sx1 " << sx1 << ", sw " << sw << ", sh " << sh << std::endl;
-    std::cerr << "Colour3DPlotLayer: sample rate is " << m_model->getSampleRate() << ", window size " << m_model->getWindowSize() << std::endl;
+    std::cerr << "Colour3DPlotLayer: sample rate is " << m_model->getSampleRate() << ", resolution " << m_model->getResolution() << std::endl;
 #endif
 
     QPoint illuminatePos;
@@ -287,13 +287,13 @@
 
     for (int sx = sx0 - 1; sx <= sx1; ++sx) {
 
-	int fx = sx * int(modelWindow);
+	int fx = sx * int(modelResolution);
 
-	if (fx + modelWindow < int(modelStart) ||
+	if (fx + modelResolution < int(modelStart) ||
 	    fx > int(modelEnd)) continue;
 
 	int rx0 = v->getXForFrame(fx + int(modelStart));
-	int rx1 = v->getXForFrame(fx + int(modelStart) + int(modelWindow));
+	int rx1 = v->getXForFrame(fx + int(modelStart) + int(modelResolution));
 
 	int w = rx1 - rx0;
 	if (w < 1) w = 1;
@@ -356,7 +356,7 @@
 
     size_t modelStart = m_model->getStartFrame();
     size_t modelEnd = m_model->getEndFrame();
-    size_t modelWindow = m_model->getWindowSize();
+    size_t modelResolution = m_model->getResolution();
 
     int x0 = rect.left();
     int x1 = rect.right() + 1;
@@ -377,8 +377,8 @@
             continue;
         }
 
-        float sx0 = (float(xf) - modelStart) / modelWindow;
-        float sx1 = (float(v->getFrameForX(x+1)) - modelStart) / modelWindow;
+        float sx0 = (float(xf) - modelStart) / modelResolution;
+        float sx1 = (float(v->getFrameForX(x+1)) - modelStart) / modelResolution;
             
         int sx0i = int(sx0 + 0.001);
         int sx1i = int(sx1);
@@ -432,7 +432,7 @@
 	return Layer::snapToFeatureFrame(v, frame, resolution, snap);
     }
 
-    resolution = m_model->getWindowSize();
+    resolution = m_model->getResolution();
     int left = (frame / resolution) * resolution;
     int right = left + resolution;
 
--- a/layer/SpectrogramLayer.cpp	Mon Jul 31 16:15:45 2006 +0000
+++ b/layer/SpectrogramLayer.cpp	Mon Jul 31 17:05:18 2006 +0000
@@ -92,7 +92,7 @@
     delete m_updateTimer;
     m_updateTimer = 0;
     
-    invalidateFFTAdapters();
+    invalidateFFTModels();
 }
 
 void
@@ -103,7 +103,7 @@
     if (model == m_model) return;
 
     m_model = model;
-    invalidateFFTAdapters();
+    invalidateFFTModels();
 
     if (!m_model || !m_model->isOK()) return;
 
@@ -579,7 +579,7 @@
 
     invalidatePixmapCaches();
     m_channel = ch;
-    invalidateFFTAdapters();
+    invalidateFFTModels();
 
     emit layerParametersChanged();
 }
@@ -600,7 +600,7 @@
     m_windowSize = ws;
     m_fftSize = ws * (m_zeroPadLevel + 1);
     
-    invalidateFFTAdapters();
+    invalidateFFTModels();
 
     emit layerParametersChanged();
 }
@@ -620,7 +620,7 @@
     
     m_windowHopLevel = v;
     
-    invalidateFFTAdapters();
+    invalidateFFTModels();
 
     emit layerParametersChanged();
 
@@ -643,7 +643,7 @@
     m_zeroPadLevel = v;
     m_fftSize = m_windowSize * (v + 1);
 
-    invalidateFFTAdapters();
+    invalidateFFTModels();
 
     emit layerParametersChanged();
 }
@@ -663,7 +663,7 @@
     
     m_windowType = w;
 
-    invalidateFFTAdapters();
+    invalidateFFTModels();
 
     emit layerParametersChanged();
 }
@@ -887,9 +887,9 @@
 	invalidatePixmapCaches();
         m_pixmapCaches.erase(v);
 
-        if (m_fftAdapters.find(v) != m_fftAdapters.end()) {
-            delete m_fftAdapters[v].first;
-            m_fftAdapters.erase(v);
+        if (m_fftModels.find(v) != m_fftModels.end()) {
+            delete m_fftModels[v].first;
+            m_fftModels.erase(v);
         }
 	
     } else {
@@ -919,19 +919,19 @@
 
     bool allDone = true;
 
-    for (ViewFFTMap::iterator i = m_fftAdapters.begin();
-         i != m_fftAdapters.end(); ++i) {
+    for (ViewFFTMap::iterator i = m_fftModels.begin();
+         i != m_fftModels.end(); ++i) {
 
         const View *v = i->first;
-        const FFTFuzzyAdapter *adapter = i->second.first;
+        const FFTModel *model = i->second.first;
         size_t lastFill = i->second.second;
 
-        if (adapter) {
-
-            size_t fill = adapter->getFillExtent();
+        if (model) {
+
+            size_t fill = model->getFillExtent();
 
 #ifdef DEBUG_SPECTROGRAM_REPAINT
-            std::cerr << "SpectrogramLayer::fillTimerTimedOut: extent for " << adapter << ": " << fill << ", last " << lastFill << ", total " << m_model->getEndFrame() << std::endl;
+            std::cerr << "SpectrogramLayer::fillTimerTimedOut: extent for " << model << ": " << fill << ", last " << lastFill << ", total " << m_model->getEndFrame() << std::endl;
 #endif
 
             if (fill >= lastFill) {
@@ -1285,7 +1285,7 @@
 
     bool logarithmic = (m_frequencyScale == LogFrequencyScale);
 
-    //!!! wrong for smoothing -- wrong fft size for fft adapter
+    //!!! wrong for smoothing -- wrong fft size for fft model
 
     q0 = v->getFrequencyForY(y, minf, maxf, logarithmic);
     q1 = v->getFrequencyForY(y - 1, minf, maxf, logarithmic);
@@ -1373,7 +1373,7 @@
 					     float &adjFreqMin, float &adjFreqMax)
 const
 {
-    FFTFuzzyAdapter *fft = getFFTAdapter(v);
+    FFTModel *fft = getFFTModel(v);
     if (!fft) return false;
 
     float s0 = 0, s1 = 0;
@@ -1463,7 +1463,7 @@
     q0i *= zp + 1;
     q1i *= zp + 1;
 
-    FFTFuzzyAdapter *fft = getFFTAdapter(v);
+    FFTModel *fft = getFFTModel(v);
 
     if (fft) {
 
@@ -1548,23 +1548,23 @@
     return m_fftSize * (getZeroPadLevel(v) + 1);
 }
 	
-FFTFuzzyAdapter *
-SpectrogramLayer::getFFTAdapter(const View *v) const
+FFTModel *
+SpectrogramLayer::getFFTModel(const View *v) const
 {
     if (!m_model) return 0;
 
     size_t fftSize = getFFTSize(v);
 
-    if (m_fftAdapters.find(v) != m_fftAdapters.end()) {
-        if (m_fftAdapters[v].first->getHeight() != fftSize / 2) {
-            delete m_fftAdapters[v].first;
-            m_fftAdapters.erase(v);
+    if (m_fftModels.find(v) != m_fftModels.end()) {
+        if (m_fftModels[v].first->getHeight() != fftSize / 2) {
+            delete m_fftModels[v].first;
+            m_fftModels.erase(v);
         }
     }
 
-    if (m_fftAdapters.find(v) == m_fftAdapters.end()) {
-        m_fftAdapters[v] = FFTFillPair
-            (new FFTFuzzyAdapter(m_model,
+    if (m_fftModels.find(v) == m_fftModels.end()) {
+        m_fftModels[v] = FFTFillPair
+            (new FFTModel(m_model,
                                  m_channel,
                                  m_windowType,
                                  m_windowSize,
@@ -1581,18 +1581,18 @@
         m_updateTimer->start(200);
     }
 
-    return m_fftAdapters[v].first;
+    return m_fftModels[v].first;
 }
 
 void
-SpectrogramLayer::invalidateFFTAdapters()
+SpectrogramLayer::invalidateFFTModels()
 {
-    for (ViewFFTMap::iterator i = m_fftAdapters.begin();
-         i != m_fftAdapters.end(); ++i) {
+    for (ViewFFTMap::iterator i = m_fftModels.begin();
+         i != m_fftModels.end(); ++i) {
         delete i->second.first;
     }
     
-    m_fftAdapters.clear();
+    m_fftModels.clear();
 }
 
 void
@@ -1673,9 +1673,9 @@
     m_dormancy[v] = false;
 
     size_t fftSize = getFFTSize(v);
-    FFTFuzzyAdapter *fft = getFFTAdapter(v);
+    FFTModel *fft = getFFTModel(v);
     if (!fft) {
-	std::cerr << "ERROR: SpectrogramLayer::paint(): No FFT adapter, returning" << std::endl;
+	std::cerr << "ERROR: SpectrogramLayer::paint(): No FFT model, returning" << std::endl;
 	return;
     }
 
@@ -2174,9 +2174,9 @@
 SpectrogramLayer::getCompletion(View *v) const
 {
     if (m_updateTimer == 0) return 100;
-    if (m_fftAdapters.find(v) == m_fftAdapters.end()) return 100;
-
-    size_t completion = m_fftAdapters[v].first->getFillCompletion();
+    if (m_fftModels.find(v) == m_fftModels.end()) return 100;
+
+    size_t completion = m_fftModels[v].first->getCompletion();
     std::cerr << "SpectrogramLayer::getCompletion: completion = " << completion << std::endl;
     return completion;
 }
--- a/layer/SpectrogramLayer.h	Mon Jul 31 16:15:45 2006 +0000
+++ b/layer/SpectrogramLayer.h	Mon Jul 31 17:05:18 2006 +0000
@@ -23,8 +23,7 @@
 #include "base/PropertyContainer.h"
 #include "data/model/PowerOfSqrtTwoZoomConstraint.h"
 #include "data/model/DenseTimeValueModel.h"
-
-#include "data/fft/FFTFuzzyAdapter.h"
+#include "data/model/FFTModel.h"
 
 #include <QMutex>
 #include <QWaitCondition>
@@ -36,7 +35,7 @@
 class QImage;
 class QPixmap;
 class QTimer;
-class FFTFuzzyAdapter;
+class FFTModel;
 
 
 /**
@@ -322,13 +321,13 @@
 
     size_t getZeroPadLevel(const View *v) const;
     size_t getFFTSize(const View *v) const;
-    FFTFuzzyAdapter *getFFTAdapter(const View *v) const;
-    void invalidateFFTAdapters();
+    FFTModel *getFFTModel(const View *v) const;
+    void invalidateFFTModels();
 
-    typedef std::pair<FFTFuzzyAdapter *, int> FFTFillPair; // adapter, last fill
+    typedef std::pair<FFTModel *, int> FFTFillPair; // model, last fill
     typedef std::map<const View *, FFTFillPair> ViewFFTMap;
     typedef std::vector<float> FloatVector;
-    mutable ViewFFTMap m_fftAdapters;
+    mutable ViewFFTMap m_fftModels;
 
     class MagnitudeRange {
     public: