diff 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
line wrap: on
line diff
--- a/base/FFTCache.h	Mon Jun 26 16:08:01 2006 +0000
+++ b/base/FFTCache.h	Mon Jun 26 16:12:11 2006 +0000
@@ -36,9 +36,16 @@
     virtual float getNormalizedMagnitudeAt(size_t x, size_t y) const = 0;
     virtual float getPhaseAt(size_t x, size_t y) const = 0;
 
+    virtual void getValuesAt(size_t x, size_t y, float &real, float &imaginary) const = 0;
+
     virtual bool haveSetColumnAt(size_t x) const = 0;
+
+    // may modify argument arrays
     virtual void setColumnAt(size_t x, float *mags, float *phases, float factor) = 0;
 
+    // may modify argument arrays
+    virtual void setColumnAt(size_t x, float *reals, float *imags) = 0;
+
     bool isLocalPeak(size_t x, size_t y) const {
         float mag = getMagnitudeAt(x, y);
         if (y > 0 && mag < getMagnitudeAt(x, y - 1)) return false;
@@ -98,6 +105,13 @@
         return (float(i) / 32767.0) * M_PI;
     }
     
+    virtual void getValuesAt(size_t x, size_t y, float &real, float &imag) const {
+        float mag = getMagnitudeAt(x, y);
+        float phase = getPhaseAt(x, y);
+        real = mag * cosf(phase);
+        imag = mag * sinf(phase);
+    }
+
     virtual void setNormalizationFactor(size_t x, float factor) {
         if (x < m_width) m_factor[x] = factor;
     }
@@ -132,6 +146,8 @@
         }
     }
 
+    virtual void setColumnAt(size_t x, float *reals, float *imags);
+
 private:
     size_t m_width;
     size_t m_height;