annotate Source/FFTW.h @ 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 636c989477e7
children
rev   line source
d@14 1 /*
d@14 2 ==============================================================================
d@1 3
d@14 4 FFTW.cpp
d@14 5 Created: 29 Oct 2014 6:30:26pm
d@14 6 Author: david.ronan
d@1 7
d@14 8 ==============================================================================
d@14 9 */
d@0 10 #pragma once
d@0 11
d@0 12 #include "fftw3.h"
d@8 13 #include <vector>
d@14 14
d@0 15
d@0 16 class FFTW
d@0 17 {
d@0 18
d@0 19 public:
d@0 20 fftwf_plan m_plan;
d@0 21 unsigned m_iFFTSize;
d@0 22
d@1 23 FFTW();
d@0 24 FFTW( unsigned fftLength )
d@0 25 {
d@0 26 m_iFFTSize = fftLength;
d@0 27
d@4 28 std::vector<float> tempInput = std::vector<float>(fftLength, 0);
d@4 29 std::vector<float> tempReal = std::vector<float>(fftLength, 0);
d@4 30 std::vector<float> tempImag = std::vector<float>(fftLength, 0);
d@4 31
d@4 32
d@0 33 fftwf_iodim dim;
d@0 34 dim.n = fftLength;
d@0 35 dim.is = 1;
d@0 36 dim.os = 1;
d@4 37 m_plan = fftwf_plan_guru_split_dft_r2c( 1, &dim, 0, nullptr, tempInput.data(), tempReal.data(), tempImag.data(), FFTW_ESTIMATE );
d@0 38 }
d@0 39
d@0 40
d@0 41 ~FFTW()
d@0 42 {
d@3 43 if(m_plan != nullptr)
d@0 44 {
d@0 45 fftwf_destroy_plan( m_plan );
d@0 46 }
d@0 47 }
d@0 48
d@0 49
d@4 50 void process(std::vector<float> input, std::vector<float> &realPart, std::vector<float> &imagPart)
d@0 51 {
d@4 52
d@4 53 fftwf_execute_split_dft_r2c( m_plan, input.data(), realPart.data(), imagPart.data());
d@0 54
d@0 55 //Multiply results by 2 to match the iOS output
d@0 56 for(size_t i = 0; i < m_iFFTSize; i++)
d@1 57 {
d@0 58 realPart[i] *= 2.f;
d@0 59 imagPart[i] *= 2.f;
d@0 60 }
d@0 61 }
d@0 62
d@0 63 };
d@0 64