annotate Source/FFTW.h @ 8:fdc592312a96

Vectorised Xcorr
author Geogaddi\David <d.m.ronan@qmul.ac.uk>
date Wed, 22 Jul 2015 15:28:00 +0100
parents 345acbd06029
children 636c989477e7
rev   line source
d@0 1 //----------------------------------------------------------------------------------------------------------------------
d@0 2 /**
d@0 3 \author André Bergner
d@0 4 \date Feb/2013
d@1 5
d@0 6 \class FFTW
d@1 7
d@0 8 Encapsulates the FFT of lib-fftw
d@1 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@8 18 #include <vector>
d@1 19 //#include <windows.h>
d@0 20 //#include <itl/dsp/SimdTools.h>
d@0 21
d@0 22
d@0 23
d@0 24 class FFTW
d@0 25 {
d@0 26
d@0 27 public:
d@0 28 fftwf_plan m_plan;
d@0 29 unsigned m_iFFTSize;
d@0 30
d@1 31 FFTW();
d@0 32 FFTW( unsigned fftLength )
d@0 33 {
d@0 34 m_iFFTSize = fftLength;
d@0 35
d@4 36 std::vector<float> tempInput = std::vector<float>(fftLength, 0);
d@4 37 std::vector<float> tempReal = std::vector<float>(fftLength, 0);
d@4 38 std::vector<float> tempImag = std::vector<float>(fftLength, 0);
d@4 39
d@4 40
d@0 41 fftwf_iodim dim;
d@0 42 dim.n = fftLength;
d@0 43 dim.is = 1;
d@0 44 dim.os = 1;
d@4 45 m_plan = fftwf_plan_guru_split_dft_r2c( 1, &dim, 0, nullptr, tempInput.data(), tempReal.data(), tempImag.data(), FFTW_ESTIMATE );
d@0 46 }
d@0 47
d@0 48
d@0 49 ~FFTW()
d@0 50 {
d@3 51 if(m_plan != nullptr)
d@0 52 {
d@0 53 fftwf_destroy_plan( m_plan );
d@0 54 }
d@0 55 }
d@0 56
d@0 57
d@4 58 void process(std::vector<float> input, std::vector<float> &realPart, std::vector<float> &imagPart)
d@0 59 {
d@4 60
d@4 61 fftwf_execute_split_dft_r2c( m_plan, input.data(), realPart.data(), imagPart.data());
d@0 62
d@0 63 //Multiply results by 2 to match the iOS output
d@0 64 for(size_t i = 0; i < m_iFFTSize; i++)
d@1 65 {
d@0 66 realPart[i] *= 2.f;
d@0 67 imagPart[i] *= 2.f;
d@0 68 }
d@0 69 }
d@0 70
d@0 71 };
d@0 72