HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
Heph::Fourier Class Referencefinal

class for calculating FFT and Convolution. More...

#include <Fourier.h>

Public Member Functions

 Fourier (const Fourier &)=delete
 
Fourieroperator= (const Fourier &)=delete
 

Static Public Member Functions

static ComplexBuffer FFT (const DoubleBuffer &doubleBuffer)
 
static ComplexBuffer FFT (const DoubleBuffer &doubleBuffer, size_t fftSize)
 
static void FFT (ComplexBuffer &complexBuffer)
 
static void FFT (ComplexBuffer &complexBuffer, size_t fftSize)
 
static void IFFT (DoubleBuffer &doubleBuffer, ComplexBuffer &complexBuffer)
 
static void IFFT (ComplexBuffer &complexBuffer, bool scale)
 
static double BinFrequencyToIndex (size_t sampleRate, size_t fftSize, double frequency)
 
static double IndexToBinFrequency (size_t sampleRate, size_t fftSize, size_t index)
 
static size_t CalculateFFTSize (size_t bufferSize)
 
static DoubleBuffer Convolve (const DoubleBuffer &source, const DoubleBuffer &kernel)
 
static DoubleBuffer Convolve (const DoubleBuffer &source, const DoubleBuffer &kernel, ConvolutionMode convolutionMode)
 

Detailed Description

class for calculating FFT and Convolution.

Note
this class cannot be instantiated.

Member Function Documentation

◆ FFT() [1/4]

static ComplexBuffer Heph::Fourier::FFT ( const DoubleBuffer & doubleBuffer)
static

computes the forward Fast Fourier Transform.

Parameters
doubleBufferreal data in time domain.
Returns
complex data in frequency domain.

◆ FFT() [2/4]

static ComplexBuffer Heph::Fourier::FFT ( const DoubleBuffer & doubleBuffer,
size_t fftSize )
static

computes the forward Fast Fourier Transform.

Parameters
doubleBufferreal data in time domain.
fftSizesize of the FFT. Must be a power of 2, if not the closest power of 2 will be used.
Returns
complex data in frequency domain.

◆ FFT() [3/4]

static void Heph::Fourier::FFT ( ComplexBuffer & complexBuffer)
static

computes the forward Fast Fourier Transform.

Parameters
complexBuffercontains the time domain data in input, and frequency domain data in output.

◆ FFT() [4/4]

static void Heph::Fourier::FFT ( ComplexBuffer & complexBuffer,
size_t fftSize )
static

computes the forward Fast Fourier Transform.

Parameters
complexBuffercontains the time domain data in input, and frequency domain data in output.
fftSizesize of the FFT. Must be a power of 2, if not the closest power of 2 will be used.

◆ IFFT() [1/2]

static void Heph::Fourier::IFFT ( DoubleBuffer & doubleBuffer,
ComplexBuffer & complexBuffer )
static

computes the inverse Fast Fourier Transform.

Parameters
doubleBufferreal data in time domain.
complexBuffercomplex data in frequency domain.

◆ IFFT() [2/2]

static void Heph::Fourier::IFFT ( ComplexBuffer & complexBuffer,
bool scale )
static

computes the inverse Fast Fourier Transform.

Parameters
complexBuffercontains the frequency domain data in input, and time domain data in output.
scaleindicates whether to divide the output by fftSize.

◆ BinFrequencyToIndex()

static double Heph::Fourier::BinFrequencyToIndex ( size_t sampleRate,
size_t fftSize,
double frequency )
static

computes the corresponding bin index to the provided frequency.

Parameters
sampleRatethe sampling rate of the transformed signal.

◆ IndexToBinFrequency()

static double Heph::Fourier::IndexToBinFrequency ( size_t sampleRate,
size_t fftSize,
size_t index )
static

computes the corresponding frequency to the provided bin index.

Parameters
sampleRatethe sampling rate of the transformed signal.

◆ CalculateFFTSize()

static size_t Heph::Fourier::CalculateFFTSize ( size_t bufferSize)
static

gets the closest power of 2 that is greater than or equal to the bufferSize.

◆ Convolve() [1/2]

static DoubleBuffer Heph::Fourier::Convolve ( const DoubleBuffer & source,
const DoubleBuffer & kernel )
static

computes convolution in Full mode.

Returns
the convolution result.

◆ Convolve() [2/2]

static DoubleBuffer Heph::Fourier::Convolve ( const DoubleBuffer & source,
const DoubleBuffer & kernel,
ConvolutionMode convolutionMode )
static

computes convolution.

Returns
the convolution result.