FFT.h — Fast Fourier Transforms¶
The FFT module provides a unified FFT interface for several popular FFT libraries. It also provides a fallback implementation if none of the supported backends are available.
- Supported Backends are
If none of the supported backends are available, the FFT module will use an implementation based on Takuya Ooura’s FFT library.
Real-To-Complex Forward FFT¶
-
Error_t
FFT_R2C(FFTConfig *fft, const float *inBuffer, float *real, float *imag)¶ Calculate Real to Complex Forward FFT.
Calculates the magnitude of the real forward FFT of the data in inBuffer.
- Return
- Error code, 0 on success.
- Parameters
fft-Pointer to the FFT configuration.
inBuffer-Input data. should be the same size as the fft.
real-Allocated buffer where the real part will be written. length should be (fft->length/2).
imag-Allocated buffer where the imaginary part will be written. l length should be (fft->length/2).
-
Error_t
FFT_R2CD(FFTConfigD *fft, const double *inBuffer, double *real, double *imag)¶
Complex-To-Real Inverse FFT¶
-
Error_t
IFFT_C2R(FFTConfig *fft, const float *inReal, const float *inImag, float *out)¶ Calculate Complex to Real Inverse FFT.
Calculates the inverse FFT of the data in inBuffer.
- Return
- Error code, 0 on success.
- Parameters
fft-Pointer to the FFT configuration.
inReal-Input real part. Length fft->length/2
inImag-Input imaginary part. Length fft->length/2
out-Allocated buffer where the signal will be written. length should be fft->length.
-
Error_t
IFFT_C2RD(FFTConfigD *fft, const double *inreal, const double *inImag, double *out)¶
FFT Convolution¶
Convolution of two real signals using the FFT.
-
Error_t
FFTConvolve(FFTConfig *fft, float *in1, unsigned in1_length, float *in2, unsigned in2_length, float *dest)¶ Perform Convolution using FFT*.
convolve in1 with in2 and write results to dest
- Return
- Error code.
- Parameters
in1-First input to convolve.
in1_length-Length [samples] of in1.
in2-Second input to convolve.
in2_length-Length[samples] of second input.
dest-Output buffer. needs to be of length in1_length + in2_length - 1
-
Error_t
FFTConvolveD(FFTConfigD *fft, const double *in1, unsigned in1_length, const double *in2, unsigned in2_length, double *dest)¶
FFT Convolution With Pre-Transformed kernel¶
Convolve a signal using a pre-transformed kernel. This is useful when using FFT convolution for filtering, as FFT(filter_kernel) only needs to be calculated once.
-
Error_t
FFTFilterConvolve(FFTConfig *fft, const float *in, unsigned in_length, FFTSplitComplex fft_ir, float *dest)¶ Perform Convolution using FFT*.
Convolve in1 with IFFT(fft_ir) and write results to dest. This takes an already transformed kernel as the second argument, to be used in an LTI filter, where the FFT of the kernel can be pre- calculated.
- Return
- Error code.
- Parameters
in1-First input to convolve.
in1_length-Length [samples] of in1.
fft_ir-Second input to convolve (Already FFT’ed).
dest-Output buffer. needs to be of length in1_length + in2_length - 1
-
Error_t
FFTFilterConvolveD(FFTConfigD *fft, const double *in, unsigned in_length, FFTSplitComplexD fft_ir, double *dest)¶