Mercurial > hg > batch-feature-extraction-tool
view Source/FFT.h @ 1:e86e9c111b29
Updates stuff that potentially fixes the memory leak and also makes it work on Windows and Linux (Need to test). Still have to fix fftw include for linux in Jucer.
author | David Ronan <d.m.ronan@qmul.ac.uk> |
---|---|
date | Thu, 09 Jul 2015 15:01:32 +0100 |
parents | 25bf17994ef1 |
children | 262e084a15a9 |
line wrap: on
line source
/* ============================================================================== FFT.h Created: 11 Aug 2014 11:18:53am Author: mickael.legoff ============================================================================== */ #ifndef FFT_H_INCLUDED #define FFT_H_INCLUDED #include "FFTW.h" template < typename FFTImpl > class FastFourierTransform { public: FastFourierTransform(); FastFourierTransform( unsigned fftLength ) : m_fft_impl( fftLength ) { m_realPart = new float[fftLength]; m_imagPart = new float[fftLength]; memset(m_realPart, 0, (fftLength)*sizeof(float)); memset(m_imagPart, 0, (fftLength)*sizeof(float)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ~FastFourierTransform() { if(m_realPart != NULL) { delete[] m_realPart; m_realPart = nullptr; } if(m_imagPart != NULL) { delete[] m_imagPart; m_imagPart = nullptr; } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void process( const float* input ) { m_fft_impl.process( input , m_realPart , m_imagPart ); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const float * realPart() { return m_realPart; } const float * imagPart() { return m_imagPart; } private: float* m_realPart; float* m_imagPart; FFTImpl m_fft_impl; }; typedef FastFourierTransform<FFTW> FFT; #endif // FFT_H_INCLUDED