Mercurial > hg > batch-feature-extraction-tool
view 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 |
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 <itl/dsp/SimdTools.h> class FFTW { public: fftwf_plan m_plan; unsigned m_iFFTSize; FFTW(); FFTW( unsigned fftLength ) { m_iFFTSize = fftLength; std::vector<float> tempInput = std::vector<float>(fftLength, 0); std::vector<float> tempReal = std::vector<float>(fftLength, 0); std::vector<float> tempImag = std::vector<float>(fftLength, 0); fftwf_iodim dim; dim.n = fftLength; dim.is = 1; dim.os = 1; m_plan = fftwf_plan_guru_split_dft_r2c( 1, &dim, 0, nullptr, tempInput.data(), tempReal.data(), tempImag.data(), FFTW_ESTIMATE ); } ~FFTW() { if(m_plan != nullptr) { fftwf_destroy_plan( m_plan ); } } void process(std::vector<float> input, std::vector<float> &realPart, std::vector<float> &imagPart) { fftwf_execute_split_dft_r2c( m_plan, input.data(), realPart.data(), imagPart.data()); //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; } } };