annotate Source/.svn/text-base/FFTW.h.svn-base @ 15:585caf503ef5 tip

Tidy up for ROLI
author Geogaddi\David <d.m.ronan@qmul.ac.uk>
date Tue, 17 May 2016 18:50:19 +0100
parents 25bf17994ef1
children
rev   line source
d@0 1 //----------------------------------------------------------------------------------------------------------------------
d@0 2 /**
d@0 3 \author André Bergner
d@0 4 \date Feb/2013
d@0 5
d@0 6 \class FFTW
d@0 7
d@0 8 Encapsulates the FFT of lib-fftw
d@0 9
d@0 10 (c) Copyright NATIVE INSTRUMENTS, Berlin, Germany
d@0 11 ALL RIGHTS RESERVED
d@0 12 */
d@0 13 //----------------------------------------------------------------------------------------------------------------------
d@0 14
d@0 15 #pragma once
d@0 16
d@0 17 #include "fftw3.h"
d@0 18 #include <vector>
d@0 19 #include <windows.h>
d@0 20 #include <string>
d@0 21 //#include <itl/dsp/SimdTools.h>
d@0 22
d@0 23
d@0 24
d@0 25 class FFTW
d@0 26 {
d@0 27
d@0 28 public:
d@0 29 fftwf_plan m_plan;
d@0 30 unsigned m_iFFTSize;
d@0 31
d@0 32 FFTW();
d@0 33 FFTW( unsigned fftLength )
d@0 34 {
d@0 35 m_iFFTSize = fftLength;
d@0 36
d@0 37 float* tempInput = new float[fftLength];
d@0 38 memset(tempInput,0, fftLength * sizeof(float));
d@0 39 float* tempReal = new float[fftLength];
d@0 40 memset(tempReal,0, fftLength * sizeof(float));
d@0 41 float* tempImag = new float[fftLength];
d@0 42 memset(tempImag,0, fftLength * sizeof(float));
d@0 43 fftwf_iodim dim;
d@0 44 dim.n = fftLength;
d@0 45 dim.is = 1;
d@0 46 dim.os = 1;
d@0 47 m_plan = fftwf_plan_guru_split_dft_r2c( 1, &dim, 0, NULL, tempInput, tempReal, tempImag, FFTW_ESTIMATE );
d@0 48 delete[] tempInput;
d@0 49 tempInput = nullptr;
d@0 50 delete[] tempReal;
d@0 51 tempReal = nullptr;
d@0 52 delete[] tempImag;
d@0 53 tempImag = nullptr;
d@0 54 }
d@0 55
d@0 56
d@0 57 ~FFTW()
d@0 58 {
d@0 59 if(m_plan != NULL)
d@0 60 {
d@0 61 fftwf_destroy_plan( m_plan );
d@0 62 }
d@0 63 }
d@0 64
d@0 65
d@0 66 void process( const float* input , float* realPart , float* imagPart )
d@0 67 {
d@0 68 float* nonConstInput = const_cast<float*>(input); // fftw does not take const input even though the data not be manipulated!
d@0 69
d@0 70 fftwf_execute_split_dft_r2c( m_plan, nonConstInput, realPart, imagPart);
d@0 71
d@0 72 //Multiply results by 2 to match the iOS output
d@0 73 for(size_t i = 0; i < m_iFFTSize; i++)
d@0 74 {
d@0 75 realPart[i] *= 2.f;
d@0 76 imagPart[i] *= 2.f;
d@0 77 }
d@0 78 }
d@0 79
d@0 80 };
d@0 81