27 #ifndef GRT_FFT_HEADER 28 #define GRT_FFT_HEADER 30 #include "../../CoreModules/FeatureExtraction.h" 31 #include "FastFourierTransform.h" 60 enum FFTWindowFunctionOptions{RECTANGULAR_WINDOW=0,BARTLETT_WINDOW,HAMMING_WINDOW,HANNING_WINDOW};
75 FFT(
const UINT fftWindowSize=512,
const UINT hopSize=1,
const UINT numDimensions=1,
const UINT fftWindowFunction=RECTANGULAR_WINDOW,
const bool computeMagnitude=
true,
const bool computePhase=
true);
95 FFT& operator=(
const FFT &rhs);
134 virtual bool clear();
143 virtual bool reset();
152 virtual bool save( std::fstream &file )
const;
161 virtual bool load( std::fstream &file );
180 bool init(
const UINT fftWindowSize,
const UINT hopSize=1,
const UINT numDimensions=1,
const UINT windowFunction=RECTANGULAR_WINDOW,
const bool computeMagnitude=
true,
const bool computePhase=
true,
const DataType inputType = DATA_TYPE_VECTOR,
const DataType outputType = DATA_TYPE_VECTOR);
190 bool update(
const Float x);
217 UINT getHopSize()
const;
224 UINT getDataBufferSize()
const;
231 UINT getFFTWindowSize()
const;
238 UINT getFFTWindowFunction()
const;
245 UINT getHopCounter()
const;
259 bool getComputePhase()
const {
if(initialized){
return computePhase; }
return false; }
282 VectorFloat getFrequencyBins(
const unsigned int sampleRate)
const;
294 bool setHopSize(
const UINT hopSize);
303 bool setFFTWindowSize(
const UINT fftWindowSize);
311 bool setFFTWindowFunction(
const UINT fftWindowFunction);
319 bool setComputeMagnitude(
const bool computeMagnitude);
327 bool setComputePhase(
const bool computePhase);
338 static std::string
getId();
341 bool isPowerOfTwo(UINT x);
342 bool validateFFTWindowFunction(UINT fftWindowFunction);
358 static std::string id;
364 #endif //GRT_FFT_HEADER bool getComputePhase() const
std::string getId() const
UINT dataBufferSize
Stores how much previous input data is stored in the dataBuffer.
Vector< FastFourierTransform > fft
A buffer used to store the FFT results.
CircularBuffer< VectorFloat > dataBuffer
A circular buffer used to store the previous M inputs.
Vector< FastFourierTransform > & getFFTResultsPtr()
UINT fftWindowFunction
The current windowFunction used for the FFT.
bool computePhase
Tracks if the phase of the FFT needs to be computed.
UINT hopSize
The current hopSize, this sets how often the fft should be computed.
UINT hopCounter
Keeps track of how many input samples the FFT has seen.
bool getComputeMagnitude() const
VectorFloat tempBuffer
A temporary buffer used to store the input data for the FFT.
virtual bool save(const std::string &filename) const
std::map< unsigned int, unsigned int > windowSizeMap
A map to relate the FFTWindowSize enumerations to actual values.
Vector< FastFourierTransform > getFFTResults() const
UINT fftWindowSize
Stores the size of the fft (and also the dataBuffer)
const Vector< FastFourierTransform > & getFFTResultsPtr() const
bool computeMagnitude
Tracks if the magnitude (and power) of the FFT need to be computed.
virtual bool load(const std::string &filename)