Mercurial > hg > batch-feature-extraction-tool
view Source/.svn/text-base/FFTW.h.svn-base @ 7:c6f38cba266d
Cleaned up redundant code
author | Geogaddi\David <d.m.ronan@qmul.ac.uk> |
---|---|
date | Wed, 22 Jul 2015 15:14:58 +0100 |
parents | 25bf17994ef1 |
children |
line wrap: on
line source
//---------------------------------------------------------------------------------------------------------------------- /** \author André Bergner \date Feb/2013 \class FFTW Encapsulates the FFT of lib-fftw (c) Copyright NATIVE INSTRUMENTS, Berlin, Germany ALL RIGHTS RESERVED */ //---------------------------------------------------------------------------------------------------------------------- #pragma once #include "fftw3.h" #include <vector> #include <windows.h> #include <string> //#include <itl/dsp/SimdTools.h> class FFTW { public: fftwf_plan m_plan; unsigned m_iFFTSize; FFTW(); FFTW( unsigned fftLength ) { m_iFFTSize = fftLength; float* tempInput = new float[fftLength]; memset(tempInput,0, fftLength * sizeof(float)); float* tempReal = new float[fftLength]; memset(tempReal,0, fftLength * sizeof(float)); float* tempImag = new float[fftLength]; memset(tempImag,0, fftLength * sizeof(float)); fftwf_iodim dim; dim.n = fftLength; dim.is = 1; dim.os = 1; m_plan = fftwf_plan_guru_split_dft_r2c( 1, &dim, 0, NULL, tempInput, tempReal, tempImag, FFTW_ESTIMATE ); delete[] tempInput; tempInput = nullptr; delete[] tempReal; tempReal = nullptr; delete[] tempImag; tempImag = nullptr; } ~FFTW() { if(m_plan != NULL) { fftwf_destroy_plan( m_plan ); } } void process( const float* input , float* realPart , float* imagPart ) { float* nonConstInput = const_cast<float*>(input); // fftw does not take const input even though the data not be manipulated! fftwf_execute_split_dft_r2c( m_plan, nonConstInput, realPart, imagPart); //Multiply results by 2 to match the iOS output for(size_t i = 0; i < m_iFFTSize; i++) { realPart[i] *= 2.f; imagPart[i] *= 2.f; } } };