Mercurial > hg > svcore
comparison base/FFTCache.h @ 128:f47f4c7c158c
* Add FFT data server class to provide a file cache mapping for each
required set of FFT parameters and source model. Make use of it in
feature extraction plugin transform, though not in other places yet.
* Add zero-pad option to spectrogram layer and remove window shape option
from the property box. To be revised.
author | Chris Cannam |
---|---|
date | Mon, 26 Jun 2006 16:12:11 +0000 |
parents | 534373d65f39 |
children | 4e38a29c13fc |
comparison
equal
deleted
inserted
replaced
127:514ebb0c5c6c | 128:f47f4c7c158c |
---|---|
34 | 34 |
35 virtual float getMagnitudeAt(size_t x, size_t y) const = 0; | 35 virtual float getMagnitudeAt(size_t x, size_t y) const = 0; |
36 virtual float getNormalizedMagnitudeAt(size_t x, size_t y) const = 0; | 36 virtual float getNormalizedMagnitudeAt(size_t x, size_t y) const = 0; |
37 virtual float getPhaseAt(size_t x, size_t y) const = 0; | 37 virtual float getPhaseAt(size_t x, size_t y) const = 0; |
38 | 38 |
39 virtual void getValuesAt(size_t x, size_t y, float &real, float &imaginary) const = 0; | |
40 | |
39 virtual bool haveSetColumnAt(size_t x) const = 0; | 41 virtual bool haveSetColumnAt(size_t x) const = 0; |
42 | |
43 // may modify argument arrays | |
40 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 | |
46 // may modify argument arrays | |
47 virtual void setColumnAt(size_t x, float *reals, float *imags) = 0; | |
41 | 48 |
42 bool isLocalPeak(size_t x, size_t y) const { | 49 bool isLocalPeak(size_t x, size_t y) const { |
43 float mag = getMagnitudeAt(x, y); | 50 float mag = getMagnitudeAt(x, y); |
44 if (y > 0 && mag < getMagnitudeAt(x, y - 1)) return false; | 51 if (y > 0 && mag < getMagnitudeAt(x, y - 1)) return false; |
45 if (y < getHeight()-1 && mag < getMagnitudeAt(x, y + 1)) return false; | 52 if (y < getHeight()-1 && mag < getMagnitudeAt(x, y + 1)) return false; |
96 virtual float getPhaseAt(size_t x, size_t y) const { | 103 virtual float getPhaseAt(size_t x, size_t y) const { |
97 int16_t i = (int16_t)m_phase[x][y]; | 104 int16_t i = (int16_t)m_phase[x][y]; |
98 return (float(i) / 32767.0) * M_PI; | 105 return (float(i) / 32767.0) * M_PI; |
99 } | 106 } |
100 | 107 |
108 virtual void getValuesAt(size_t x, size_t y, float &real, float &imag) const { | |
109 float mag = getMagnitudeAt(x, y); | |
110 float phase = getPhaseAt(x, y); | |
111 real = mag * cosf(phase); | |
112 imag = mag * sinf(phase); | |
113 } | |
114 | |
101 virtual void setNormalizationFactor(size_t x, float factor) { | 115 virtual void setNormalizationFactor(size_t x, float factor) { |
102 if (x < m_width) m_factor[x] = factor; | 116 if (x < m_width) m_factor[x] = factor; |
103 } | 117 } |
104 | 118 |
105 virtual void setMagnitudeAt(size_t x, size_t y, float mag) { | 119 virtual void setMagnitudeAt(size_t x, size_t y, float mag) { |
130 setMagnitudeAt(x, y, mags[y]); | 144 setMagnitudeAt(x, y, mags[y]); |
131 setPhaseAt(x, y, phases[y]); | 145 setPhaseAt(x, y, phases[y]); |
132 } | 146 } |
133 } | 147 } |
134 | 148 |
149 virtual void setColumnAt(size_t x, float *reals, float *imags); | |
150 | |
135 private: | 151 private: |
136 size_t m_width; | 152 size_t m_width; |
137 size_t m_height; | 153 size_t m_height; |
138 uint16_t **m_magnitude; | 154 uint16_t **m_magnitude; |
139 uint16_t **m_phase; | 155 uint16_t **m_phase; |