diff data/model/FFTModel.h @ 1093:44b079427b36 simple-fft-model

Make a small cache of recently-used columns
author Chris Cannam
date Fri, 12 Jun 2015 18:50:52 +0100
parents 70f18770b72d
children b386363ff6c8
line wrap: on
line diff
--- a/data/model/FFTModel.h	Fri Jun 12 18:20:09 2015 +0100
+++ b/data/model/FFTModel.h	Fri Jun 12 18:50:52 2015 +0100
@@ -24,9 +24,9 @@
 #include "data/fft/FFTapi.h"
 
 #include <set>
-#include <map>
 #include <vector>
 #include <complex>
+#include <deque>
 
 /**
  * An implementation of DenseThreeDimensionalModel that makes FFT data
@@ -80,7 +80,9 @@
     virtual bool shouldUseLogValueScale() const { return true; }
     virtual int getCompletion() const {
         int c = 100;
-        if (m_model) (void)m_model->isReady(&c);
+        if (m_model) {
+            if (m_model->isReady(&c)) return 100;
+        }
         return c;
     }
     virtual QString getError() const { return ""; } //!!!???
@@ -166,6 +168,16 @@
 
     std::vector<std::complex<float> > getFFTColumn(int column) const;
     std::vector<float> getSourceSamples(int column) const;
+
+    struct SavedColumn {
+        int n;
+        std::vector<std::complex<float> > col;
+    };
+    
+    mutable std::deque<SavedColumn> m_cached;
+    size_t m_cacheSize;
+
+    //!!! also optionally cache polar?
 };
 
 #endif