r8brain-free-src
High-quality pro audio sample rate converter library
 
Loading...
Searching...
No Matches
r8b::CDSPRealFFT Class Reference

Real-valued FFT transform class. More...

#include <CDSPRealFFT.h>

Inheritance diagram for r8b::CDSPRealFFT:
r8b::CSinglyLinkedListItem< CDSPRealFFT >

Public Member Functions

void convertToZP (realfft_t *const p) const
 Converts the specified forward-transformed FFT block into "zero-phase" form, suitable for use with the multiplyBlocksZP() function.
 
realfft_tforward (double *const p) const
 Performs in-place forward FFT.
 
double getInvMulConst () const
 Return a multiplication constant that should be used after inverse transform to obtain a correct value scale.
 
int getLen () const
 Returns the length (the number of real values in a transform) of this FFT object.
 
int getLenBits () const
 Returns the length (the number of real values in a transform) of this FFT object, expressed as Nth power of 2.
 
realfft_tgetWorkBuf () const
 Returns pointer to the internal work buffer.
 
void inverse (realfft_t *const p) const
 Performs in-place inverse FFT.
 
void multiplyBlocks (const realfft_t *const ip, realfft_t *const op) const
 Multiplies two complex-valued FFT blocks in-place.
 
void multiplyBlocks (const realfft_t *const ip1, const realfft_t *const ip2, realfft_t *const op) const
 Multiplies two complex-valued data blocks and places result in a new data block.
 
void multiplyBlocksZP (const realfft_t *ip, realfft_t *op) const
 Multiplies two complex-valued FFT blocks in-place, considering that the ip block contains "zero-phase" response.
 
realfft_treorderForward (realfft_t *const p, realfft_t *const op) const
 Reorders FFT bins from native ordering (after the forward transform) to sequential ordering.
 
realfft_treorderInverse (const realfft_t *const ip, double *const op) const
 Reorders FFT bins from sequential ordering (before the inverse transform) to native ordering.
 

Static Public Member Functions

static void setBinNyquist (realfft_t *const p, const realfft_t v)
 Replaces the Nyquist FFT bin in the specified block.
 

Friends

class CDSPRealFFTKeeper
 
class CPtrKeeper< CDSPRealFFT >
 
class CSinglyLinkedListItem< CDSPRealFFT >
 

Detailed Description

Real-valued FFT transform class.

Class implements a wrapper for real-valued discrete fast Fourier transform functions. The object of this class can only be obtained via the CDSPRealFFTKeeper class.

As a general pre-condition, the buffers passed to the functions of this class should be aligned to 32 bytes.

Uses functions from the FFT package: http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html

Also uses functions from the PFFFT and PFFFT DOUBLE packages.

Also uses Intel IPP library functions if available (if the R8B_IPP=1 macro was defined). Note that IPP library's FFT functions are 2-3 times more efficient on the modern Intel Core i7-3770K processor than Ooura's functions. It may be worthwhile investing in IPP. Note, that FFT functions take less than 20% of the overall sample rate conversion time. However, when the "power of 2" resampling is used the performance of FFT functions dominates.

Member Function Documentation

◆ convertToZP()

void r8b::CDSPRealFFT::convertToZP ( realfft_t *const p) const

Converts the specified forward-transformed FFT block into "zero-phase" form, suitable for use with the multiplyBlocksZP() function.

Parameters
[in,out]pBlock to transform.

◆ forward()

realfft_t * r8b::CDSPRealFFT::forward ( double *const p) const

Performs in-place forward FFT.

If FFT's native type differs from double, the result will be placed to p using values of the native type.

Parameters
[in,out]pPointer to data block to transform, length should be equal to this object's getLen().
Returns
The pointer p casted to transform's native type.

◆ getWorkBuf()

realfft_t * r8b::CDSPRealFFT::getWorkBuf ( ) const

Returns pointer to the internal work buffer.

This buffer can be used for FFT bin reordering.

Returns
The work buffer pointer, or nullptr if FFT produces sequential-ordered FFT bins. This pointer should not be used beyond the calling context.

◆ inverse()

void r8b::CDSPRealFFT::inverse ( realfft_t *const p) const

Performs in-place inverse FFT.

If FFT's native type differs from double, the result will be placed to p using double values.

Parameters
[in,out]pPointer to data block to transform, length should be equal to this object's getLen().

◆ multiplyBlocks() [1/2]

void r8b::CDSPRealFFT::multiplyBlocks ( const realfft_t *const ip,
realfft_t *const op ) const

Multiplies two complex-valued FFT blocks in-place.

Length of both blocks should be equal to this object's block length. Blocks should have been produced with the forward() function of this object.

Parameters
ipInput FFT block 1.
[in,out]opOutput/input FFT block 2.

◆ multiplyBlocks() [2/2]

void r8b::CDSPRealFFT::multiplyBlocks ( const realfft_t *const ip1,
const realfft_t *const ip2,
realfft_t *const op ) const

Multiplies two complex-valued data blocks and places result in a new data block.

Length of all data blocks should be equal to this object's block length. Input blocks should have been produced with the forward() function of this object.

Parameters
ip1Input FFT block 1.
ip2Input FFT block 2.
[out]opOutput FFT block, should not be equal to ip1 nor ip2.

◆ multiplyBlocksZP()

void r8b::CDSPRealFFT::multiplyBlocksZP ( const realfft_t * ip,
realfft_t * op ) const

Multiplies two complex-valued FFT blocks in-place, considering that the ip block contains "zero-phase" response.

Length of both blocks should be equal to this object's block length. Blocks should have been produced with the forward() function of this object.

Parameters
ipInput FFT block 1, "zero-phase" response. This block should be first transformed via the convertToZP() function.
[in,out]opOutput/input FFT block 2.

◆ reorderForward()

realfft_t * r8b::CDSPRealFFT::reorderForward ( realfft_t *const p,
realfft_t *const op ) const

Reorders FFT bins from native ordering (after the forward transform) to sequential ordering.

Parameters
pInput FFT block.
opOutput FFT block.
Returns
The pointer to the reordered FFT block. May return p if the transform has sequential ordering already.

◆ reorderInverse()

realfft_t * r8b::CDSPRealFFT::reorderInverse ( const realfft_t *const ip,
double *const op ) const

Reorders FFT bins from sequential ordering (before the inverse transform) to native ordering.

Parameters
ipPointer to FFT block (previously returned by the reorderForward() function).
opOutput FFT block (may equal ip).
Returns
The pointer to the reordered FFT block (op casted to the realfft_t type).

◆ setBinNyquist()

static void r8b::CDSPRealFFT::setBinNyquist ( realfft_t *const p,
const realfft_t v )
static

Replaces the Nyquist FFT bin in the specified block.

Parameters
pPointer to FFT block.
vNew Nyquist bin value.