diff data/model/FFTModel.h @ 1091:bdebff3265ae simple-fft-model

Simplest naive FFTModel implementation (+ fill in tests)
author Chris Cannam
date Fri, 12 Jun 2015 18:08:57 +0100
parents 420fc961c0c4
children 70f18770b72d
line wrap: on
line diff
--- a/data/model/FFTModel.h	Fri Jun 12 14:51:46 2015 +0100
+++ b/data/model/FFTModel.h	Fri Jun 12 18:08:57 2015 +0100
@@ -21,8 +21,12 @@
 
 #include "base/Window.h"
 
+#include "data/fft/FFTapi.h"
+
 #include <set>
 #include <map>
+#include <vector>
+#include <complex>
 
 /**
  * An implementation of DenseThreeDimensionalModel that makes FFT data
@@ -88,7 +92,6 @@
     int getFFTSize() const { return m_fftSize; }
     
     float getMagnitudeAt(int x, int y) const;
-    float getNormalizedMagnitudeAt(int x, int y) const;
     float getMaximumMagnitudeAt(int x) const;
     float getPhaseAt(int x, int y) const;
     void getValuesAt(int x, int y, float &real, float &imaginary) const;
@@ -144,9 +147,22 @@
     int m_windowIncrement;
     int m_fftSize;
     Window<float> m_windower;
+    FFTForward m_fft;
     
     int getPeakPickWindowSize(PeakPickType type, sv_samplerate_t sampleRate,
                               int bin, float &percentile) const;
+
+    std::pair<sv_frame_t, sv_frame_t> getSourceSampleRange(int column) const {
+        sv_frame_t startFrame = m_windowIncrement * sv_frame_t(column);
+        sv_frame_t endFrame = startFrame + m_windowSize;
+        // Cols are centred on the audio sample (e.g. col 0 is centred at sample 0)
+        startFrame -= m_windowSize / 2;
+        endFrame -= m_windowSize / 2;
+        return { startFrame, endFrame };
+    }
+
+    std::vector<std::complex<float> > getFFTColumn(int column) const;
+    std::vector<float> getSourceSamples(int column) const;
 };
 
 #endif