The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
Fast Fourier Transform functions
Collaboration diagram for Fast Fourier Transform functions:

Typedefs

typedef void * mha_fft_t
 Handle for an FFT object. More...
 

Functions

mha_fft_t mha_fft_new (unsigned int n)
 Create a new FFT handle. More...
 
void mha_fft_free (mha_fft_t h)
 Destroy an FFT handle. More...
 
void mha_fft_wave2spec (mha_fft_t h, const mha_wave_t *in, mha_spec_t *out)
 Tranform waveform segment into spectrum. More...
 
void mha_fft_wave2spec (mha_fft_t h, const mha_wave_t *in, mha_spec_t *out, bool swaps)
 Tranform waveform segment into spectrum. More...
 
void mha_fft_spec2wave (mha_fft_t h, const mha_spec_t *in, mha_wave_t *out)
 Tranform spectrum into waveform segment. More...
 
void mha_fft_spec2wave (mha_fft_t h, const mha_spec_t *in, mha_wave_t *out, unsigned int offset)
 Tranform spectrum into waveform segment. out may have fewer number of frames than needed for a complete iFFT. Only as many frames are written into out as fit, starting with offset offset of the complete iFFT. More...
 
void mha_fft_forward (mha_fft_t h, mha_spec_t *sIn, mha_spec_t *sOut)
 Complex to complex FFT (forward). More...
 
void mha_fft_backward (mha_fft_t h, mha_spec_t *sIn, mha_spec_t *sOut)
 Complex to complex FFT (backward). More...
 
void mha_fft_forward_scale (mha_fft_t h, mha_spec_t *sIn, mha_spec_t *sOut)
 Complex to complex FFT (forward). More...
 
void mha_fft_backward_scale (mha_fft_t h, mha_spec_t *sIn, mha_spec_t *sOut)
 Complex to complex FFT (backward). More...
 
void mha_fft_wave2spec_scale (mha_fft_t h, const mha_wave_t *in, mha_spec_t *out)
 Tranform waveform segment into spectrum. More...
 
void mha_fft_spec2wave_scale (mha_fft_t h, const mha_spec_t *in, mha_wave_t *out)
 Tranform spectrum into waveform segment. More...
 

Detailed Description

Typedef Documentation

◆ mha_fft_t

typedef void* mha_fft_t

Handle for an FFT object.

This FFT object is used by the functions mha_fft_wave2spec and mha_fft_spec2wave. The FFT back-end is the FFTW library. The back-end is completely hidden, including external header files or linking external libraries is not required.

Function Documentation

◆ mha_fft_new()

mha_fft_t mha_fft_new ( unsigned int  n)

Create a new FFT handle.

Parameters
nFFT length.

Create a new FFT handle.

Parameters
nFFT length
Return values
FFTobject

◆ mha_fft_free()

void mha_fft_free ( mha_fft_t  h)

Destroy an FFT handle.

Parameters
hHandle to be destroyed.

Destroy an FFT handle.

Parameters
hFFT object to be removed

◆ mha_fft_wave2spec() [1/2]

void mha_fft_wave2spec ( mha_fft_t  h,
const mha_wave_t in,
mha_spec_t out 
)

Tranform waveform segment into spectrum.

Parameters
hFFT handle.
inInput waveform segment.
outOutput spectrum.

Tranform waveform segment into spectrum.

Parameters
hFFT object handle
inpointer to input waveform signal
outpointer to output spectrum signal (has to be allocated)

◆ mha_fft_wave2spec() [2/2]

void mha_fft_wave2spec ( mha_fft_t  h,
const mha_wave_t in,
mha_spec_t out,
bool  swaps 
)

Tranform waveform segment into spectrum.

Like normal wave2spec, but swaps wave buffer halves before transforming if the swaps parameter is true.

Warning: These openMHA FFTs adopt a nonstandard scaling scheme in which the forward transform scales by 1/N and the backward does not scale. We would recommend using the '_scale' methods instead.

Parameters
hFFT handle.
inInput waveform segment.
outOutput spectrum.
swapsFunction swaps the first and second half of the waveform buffer before the FFT transform when this parameter is set to true.

◆ mha_fft_spec2wave() [1/2]

void mha_fft_spec2wave ( mha_fft_t  h,
const mha_spec_t in,
mha_wave_t out 
)

Tranform spectrum into waveform segment.

Warning: These openMHA FFTs adopt a nonstandard scaling scheme in which the forward transform scales by 1/N and the backward does not scale. We would recommend using the '_scale' methods instead.

Parameters
hFFT handle.
inInput spectrum.
outOutput waveform segment.

Tranform spectrum into waveform segment.

Parameters
hFFT object handle
inpointer to input spectrum
outpointer to output waveform signal (has to be allocated)

◆ mha_fft_spec2wave() [2/2]

void mha_fft_spec2wave ( mha_fft_t  h,
const mha_spec_t in,
mha_wave_t out,
unsigned int  offset 
)

Tranform spectrum into waveform segment. out may have fewer number of frames than needed for a complete iFFT. Only as many frames are written into out as fit, starting with offset offset of the complete iFFT.

Warning: These openMHA FFTs adopt a nonstandard scaling scheme in which the forward transform scales by 1/N and the backward does not scale. We would recommend using the '_scale' methods instead.

Parameters
hFFT handle.
inInput spectrum.
outOutput waveform segment.
offsetOffset into iFFT wave buffer

Tranform spectrum into waveform segment. out may have fewer number of frames than needed for a complete iFFT. Only as many frames are written into out as fit, starting with offset offset of the complete iFFT.

Only part of the iFFT is tranferred into the out buffer.

Out may have fewer number of freames than needed for a complete iFFT. Only as many frames are written into out as fit, starting with offset offset of the complete iFFT.

Parameters
hFFT object handle
inpointer to input spectrum
outpointer to output waveform signal (has to be allocated)
offsetOffset into complete iFFT buffer.

◆ mha_fft_forward()

void mha_fft_forward ( mha_fft_t  h,
mha_spec_t sIn,
mha_spec_t sOut 
)

Complex to complex FFT (forward).

sIn and sOut need to have nfft bins (please note that mha_spec_t typically has nfft/2+1 bins for half-complex representation).

Warning: These openMHA FFTs adopt a nonstandard scaling scheme in which the forward transform scales by 1/N and the backward does not scale. We would recommend using the '_scale' methods instead.

Parameters
hFFT handle.
sInInput spectrum.
sOutOutput spectrum.

◆ mha_fft_backward()

void mha_fft_backward ( mha_fft_t  h,
mha_spec_t sIn,
mha_spec_t sOut 
)

Complex to complex FFT (backward).

sIn and sOut need to have nfft bins (please note that mha_spec_t typically has nfft/2+1 bins for half-complex representation).

Warning: These openMHA FFTs adopt a nonstandard scaling scheme in which the forward transform scales by 1/N and the backward does not scale. We would recommend using the '_scale' methods instead.

Parameters
hFFT handle.
sInInput spectrum.
sOutOutput spectrum.

◆ mha_fft_forward_scale()

void mha_fft_forward_scale ( mha_fft_t  h,
mha_spec_t sIn,
mha_spec_t sOut 
)

Complex to complex FFT (forward).

sIn and sOut need to have nfft bins (please note that mha_spec_t typically has nfft/2+1 bins for half-complex representation).

The _scale methods use standard DFT scaling: There is no scaling in the forward transformation, and 1/N scaling for the backward.

Parameters
hFFT handle.
sInInput spectrum.
sOutOutput spectrum.

◆ mha_fft_backward_scale()

void mha_fft_backward_scale ( mha_fft_t  h,
mha_spec_t sIn,
mha_spec_t sOut 
)

Complex to complex FFT (backward).

sIn and sOut need to have nfft bins (please note that mha_spec_t typically has nfft/2+1 bins for half-complex representation).

The _scale methods use standard DFT scaling: There is no scaling in the forward transformation, and 1/N scaling for the backward.

Parameters
hFFT handle.
sInInput spectrum.
sOutOutput spectrum.

◆ mha_fft_wave2spec_scale()

void mha_fft_wave2spec_scale ( mha_fft_t  h,
const mha_wave_t in,
mha_spec_t out 
)

Tranform waveform segment into spectrum.

The _scale methods use standard DFT scaling: There is no scaling in the forward transformation, and 1/N scaling for the backward.

Parameters
hFFT handle.
inInput waveform segment.
outOutput spectrum.

◆ mha_fft_spec2wave_scale()

void mha_fft_spec2wave_scale ( mha_fft_t  h,
const mha_spec_t in,
mha_wave_t out 
)

Tranform spectrum into waveform segment.

The _scale methods use standard DFT scaling: There is no scaling in the forward transformation, and 1/N scaling for the backward.

Parameters
hFFT handle.
inInput spectrum.
outOutput waveform segment.