comparison base/FFTCache.h @ 129:4e38a29c13fc

* Split large FFT caches up into several files. Ongoing.
author Chris Cannam
date Wed, 28 Jun 2006 13:41:12 +0000
parents f47f4c7c158c
children 69d50575c52a
comparison
equal deleted inserted replaced
128:f47f4c7c158c 129:4e38a29c13fc
19 #include <cstdlib> 19 #include <cstdlib>
20 #include <cmath> 20 #include <cmath>
21 21
22 #include <stdint.h> 22 #include <stdint.h>
23 23
24 class FFTCacheBase 24 class FFTCache
25 { 25 {
26 public: 26 public:
27 virtual ~FFTCacheBase() { } 27 virtual ~FFTCache() { }
28 28
29 virtual size_t getWidth() const = 0; 29 virtual size_t getWidth() const = 0;
30 virtual size_t getHeight() const = 0; 30 virtual size_t getHeight() const = 0;
31 31
32 virtual void resize(size_t width, size_t height) = 0; 32 virtual void resize(size_t width, size_t height) = 0;
44 virtual void setColumnAt(size_t x, float *mags, float *phases, float factor) = 0; 44 virtual void setColumnAt(size_t x, float *mags, float *phases, float factor) = 0;
45 45
46 // may modify argument arrays 46 // may modify argument arrays
47 virtual void setColumnAt(size_t x, float *reals, float *imags) = 0; 47 virtual void setColumnAt(size_t x, float *reals, float *imags) = 0;
48 48
49 virtual void suspend() { }
50
49 bool isLocalPeak(size_t x, size_t y) const { 51 bool isLocalPeak(size_t x, size_t y) const {
50 float mag = getMagnitudeAt(x, y); 52 float mag = getMagnitudeAt(x, y);
51 if (y > 0 && mag < getMagnitudeAt(x, y - 1)) return false; 53 if (y > 0 && mag < getMagnitudeAt(x, y - 1)) return false;
52 if (y < getHeight()-1 && mag < getMagnitudeAt(x, y + 1)) return false; 54 if (y < getHeight()-1 && mag < getMagnitudeAt(x, y + 1)) return false;
53 return true; 55 return true;
55 bool isOverThreshold(size_t x, size_t y, float threshold) const { 57 bool isOverThreshold(size_t x, size_t y, float threshold) const {
56 return getMagnitudeAt(x, y) > threshold; 58 return getMagnitudeAt(x, y) > threshold;
57 } 59 }
58 60
59 protected: 61 protected:
60 FFTCacheBase() { } 62 FFTCache() { }
61 }; 63 };
62 64
63 65
64 /** 66 /**
65 * For the in-memory FFT cache, we would like to cache magnitude with 67 * For the in-memory FFT cache, we would like to cache magnitude with
78 * to [0,1] with respect to the column, so the normalization 80 * to [0,1] with respect to the column, so the normalization
79 * factor should be calculated before all values in a column, and 81 * factor should be calculated before all values in a column, and
80 * set appropriately. 82 * set appropriately.
81 */ 83 */
82 84
83 class FFTMemoryCache : public FFTCacheBase 85 class FFTMemoryCache : public FFTCache
84 { 86 {
85 public: 87 public:
86 FFTMemoryCache(); // of size zero, call resize() before using 88 FFTMemoryCache(); // of size zero, call resize() before using
87 virtual ~FFTMemoryCache(); 89 virtual ~FFTMemoryCache();
88 90