annotate Source/FFTW.h @ 4:345acbd06029

Vectorised most things to make lifer easier. Still no debug version though. Weird.
author Geogaddi\David <d.m.ronan@qmul.ac.uk>
date Fri, 10 Jul 2015 03:04:11 +0100
parents 005e311b5e62
children fdc592312a96
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@1 18 #include <vector>
d@4 19 #include <memory>
d@1 20 #include <stdio.h>
d@1 21 //#include <windows.h>
d@1 22 #include <string.h>
d@0 23 //#include <itl/dsp/SimdTools.h>
d@0 24
d@0 25
d@0 26
d@0 27 class FFTW
d@0 28 {
d@0 29
d@0 30 public:
d@0 31 fftwf_plan m_plan;
d@0 32 unsigned m_iFFTSize;
d@0 33
d@1 34 FFTW();
d@0 35 FFTW( unsigned fftLength )
d@0 36 {
d@0 37 m_iFFTSize = fftLength;
d@0 38
d@4 39 std::vector<float> tempInput = std::vector<float>(fftLength, 0);
d@4 40 std::vector<float> tempReal = std::vector<float>(fftLength, 0);
d@4 41 std::vector<float> tempImag = std::vector<float>(fftLength, 0);
d@4 42
d@4 43
d@0 44 fftwf_iodim dim;
d@0 45 dim.n = fftLength;
d@0 46 dim.is = 1;
d@0 47 dim.os = 1;
d@4 48 m_plan = fftwf_plan_guru_split_dft_r2c( 1, &dim, 0, nullptr, tempInput.data(), tempReal.data(), tempImag.data(), FFTW_ESTIMATE );
d@0 49 }
d@0 50
d@0 51
d@0 52 ~FFTW()
d@0 53 {
d@3 54 if(m_plan != nullptr)
d@0 55 {
d@0 56 fftwf_destroy_plan( m_plan );
d@0 57 }
d@0 58 }
d@0 59
d@0 60
d@4 61 void process(std::vector<float> input, std::vector<float> &realPart, std::vector<float> &imagPart)
d@0 62 {
d@4 63
d@4 64 fftwf_execute_split_dft_r2c( m_plan, input.data(), realPart.data(), imagPart.data());
d@0 65
d@0 66 //Multiply results by 2 to match the iOS output
d@0 67 for(size_t i = 0; i < m_iFFTSize; i++)
d@1 68 {
d@0 69 realPart[i] *= 2.f;
d@0 70 imagPart[i] *= 2.f;
d@0 71 }
d@0 72 }
d@0 73
d@0 74 };
d@0 75