comparison 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
comparison
equal deleted inserted replaced
1092:70f18770b72d 1093:44b079427b36
22 #include "base/Window.h" 22 #include "base/Window.h"
23 23
24 #include "data/fft/FFTapi.h" 24 #include "data/fft/FFTapi.h"
25 25
26 #include <set> 26 #include <set>
27 #include <map>
28 #include <vector> 27 #include <vector>
29 #include <complex> 28 #include <complex>
29 #include <deque>
30 30
31 /** 31 /**
32 * An implementation of DenseThreeDimensionalModel that makes FFT data 32 * An implementation of DenseThreeDimensionalModel that makes FFT data
33 * derived from a DenseTimeValueModel available as a generic data 33 * derived from a DenseTimeValueModel available as a generic data
34 * grid. 34 * grid.
78 virtual Column getColumn(int x) const; // magnitudes 78 virtual Column getColumn(int x) const; // magnitudes
79 virtual QString getBinName(int n) const; 79 virtual QString getBinName(int n) const;
80 virtual bool shouldUseLogValueScale() const { return true; } 80 virtual bool shouldUseLogValueScale() const { return true; }
81 virtual int getCompletion() const { 81 virtual int getCompletion() const {
82 int c = 100; 82 int c = 100;
83 if (m_model) (void)m_model->isReady(&c); 83 if (m_model) {
84 if (m_model->isReady(&c)) return 100;
85 }
84 return c; 86 return c;
85 } 87 }
86 virtual QString getError() const { return ""; } //!!!??? 88 virtual QString getError() const { return ""; } //!!!???
87 virtual sv_frame_t getFillExtent() const { return getEndFrame(); } 89 virtual sv_frame_t getFillExtent() const { return getEndFrame(); }
88 90
164 return { startFrame, endFrame }; 166 return { startFrame, endFrame };
165 } 167 }
166 168
167 std::vector<std::complex<float> > getFFTColumn(int column) const; 169 std::vector<std::complex<float> > getFFTColumn(int column) const;
168 std::vector<float> getSourceSamples(int column) const; 170 std::vector<float> getSourceSamples(int column) const;
171
172 struct SavedColumn {
173 int n;
174 std::vector<std::complex<float> > col;
175 };
176
177 mutable std::deque<SavedColumn> m_cached;
178 size_t m_cacheSize;
179
180 //!!! also optionally cache polar?
169 }; 181 };
170 182
171 #endif 183 #endif