DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::detail::fft::SplitFFT< T > Class Template Reference

The shared Stockham engine: a forward complex FFT of size N on split (re, im) arrays, ping-ponging between two work buffers. More...

#include <FFT.h>

Public Member Functions

 SplitFFT ()=default
 
 SplitFFT (size_t n, bool interleavedInput=false)
 
size_t size () const noexcept
 
T * inRe () noexcept
 Input buffers: fill inRe() / inIm() with N values each before run().
 
T * inIm () noexcept
 
void run (const T *&outRe, const T *&outIm) noexcept
 Runs the forward transform of the input buffers.
 
void runFrom (const T *data, bool conjugate, const T *&outRe, const T *&outIm) noexcept
 Transforms interleaved (re, im) pairs, conjugated if asked, without first copying them into the input buffers.
 
void runFromSplit (const T *re, const T *im, const T *&outRe, const T *&outIm) noexcept
 Transforms N values read from two arrays of real and imaginary parts, without first copying them into the input buffers.
 
void runScaledSwap (const T *re, const T *im, const T *gain, size_t mask, const T *&outRe, const T *&outIm) noexcept
 Transforms the spectrum product whose bin k is (im[k & mask] gain[k], re[k & mask] gain[k]), read straight from the arrays. Run on a product's swapped parts, a forward transform is its inverse with the parts swapped back on the way out, so this is a filter's multiply and inverse in one go. The product is never stored, so a build that contracts multiply-adds may fuse it into the first pass: one rounding fewer than writing it to the input buffers first and calling run().
 
void runScaledSwapFolded (const T *re, const T *im, const T *gain, size_t fold, const T *&outRe, const T *&outIm) noexcept
 runScaledSwap() of a spectrum fold times this engine's size, folded: bin k sums the products of bins k + f N, f < fold. The result is the inverse of the product at every fold-th sample, exact when the product holds nothing the fold aliases (a filter whose stopband starts at the decimated Nyquist).
 
void runTo (T *out, T scaleRe, T scaleIm) noexcept
 Transforms the input buffers and writes interleaved output directly.
 
void runFromTo (const T *data, bool conjugate, T *out, T scaleRe, T scaleIm) noexcept
 
size_t runToStepCount () const noexcept
 
void runToStep (size_t step, T *out, T scaleRe, T scaleIm) noexcept
 Runs one step of runTo(): step s below runToStepCount() - 1 is pass s, the last step the closing pass into out. All steps in order, with nothing else run in between, equal runTo() bit for bit (the passes alternate between the two work buffers, so the buffer a step reads follows from its index). Step 0 chooses the kernel set and the later steps keep it, as runTo() does.
 

Static Public Member Functions

static size_t allocationBytes (size_t n, bool interleavedInput) noexcept
 Upper bound of the bytes the constructor requests for a power-of-two size n: the two work buffers (one allocation), the twiddle tables and the pass plan (one each), plus kAllocationOverhead per allocation. Allocates nothing.
 

Static Public Attributes

static constexpr size_t kAllocationOverhead = 64
 

Detailed Description

template<typename T>
class dspark::detail::fft::SplitFFT< T >

The shared Stockham engine: a forward complex FFT of size N on split (re, im) arrays, ping-ponging between two work buffers.

Definition at line 452 of file FFT.h.

Constructor & Destructor Documentation

◆ SplitFFT() [1/2]

template<typename T >
dspark::detail::fft::SplitFFT< T >::SplitFFT ( )
default

An engine that holds nothing and must not be run (a real transform of a size that runs by lanes keeps one of these).

◆ SplitFFT() [2/2]

template<typename T >
dspark::detail::fft::SplitFFT< T >::SplitFFT ( size_t  n,
bool  interleavedInput = false 
)
inlineexplicit

Definition at line 459 of file FFT.h.

Member Function Documentation

◆ allocationBytes()

template<typename T >
static size_t dspark::detail::fft::SplitFFT< T >::allocationBytes ( size_t  n,
bool  interleavedInput 
)
inlinestaticnoexcept

Upper bound of the bytes the constructor requests for a power-of-two size n: the two work buffers (one allocation), the twiddle tables and the pass plan (one each), plus kAllocationOverhead per allocation. Allocates nothing.

Definition at line 536 of file FFT.h.

◆ inIm()

template<typename T >
T * dspark::detail::fft::SplitFFT< T >::inIm ( )
inlinenoexcept

Definition at line 551 of file FFT.h.

◆ inRe()

template<typename T >
T * dspark::detail::fft::SplitFFT< T >::inRe ( )
inlinenoexcept

Input buffers: fill inRe() / inIm() with N values each before run().

Definition at line 550 of file FFT.h.

◆ run()

template<typename T >
void dspark::detail::fft::SplitFFT< T >::run ( const T *&  outRe,
const T *&  outIm 
)
inlinenoexcept

Runs the forward transform of the input buffers.

Parameters
outReReceives the pointer to the N output real parts.
outImReceives the pointer to the N output imaginary parts.

Definition at line 558 of file FFT.h.

◆ runFrom()

template<typename T >
void dspark::detail::fft::SplitFFT< T >::runFrom ( const T *  data,
bool  conjugate,
const T *&  outRe,
const T *&  outIm 
)
inlinenoexcept

Transforms interleaved (re, im) pairs, conjugated if asked, without first copying them into the input buffers.

Parameters
dataN interleaved complex values.
conjugateConjugates the input.
outReReceives the pointer to the N output real parts.
outImReceives the pointer to the N output imaginary parts.

Definition at line 580 of file FFT.h.

◆ runFromSplit()

template<typename T >
void dspark::detail::fft::SplitFFT< T >::runFromSplit ( const T *  re,
const T *  im,
const T *&  outRe,
const T *&  outIm 
)
inlinenoexcept

Transforms N values read from two arrays of real and imaginary parts, without first copying them into the input buffers.

Parameters
reN real parts (outside this engine's buffers).
imN imaginary parts (outside this engine's buffers).
outReReceives the pointer to the N output real parts.
outImReceives the pointer to the N output imaginary parts.

Definition at line 612 of file FFT.h.

◆ runFromTo()

template<typename T >
void dspark::detail::fft::SplitFFT< T >::runFromTo ( const T *  data,
bool  conjugate,
T *  out,
T  scaleRe,
T  scaleIm 
)
inlinenoexcept

runFrom() and runTo() together. A transform of one pass cannot do both in that pass, so it reads through the input buffers.

Definition at line 724 of file FFT.h.

◆ runScaledSwap()

template<typename T >
void dspark::detail::fft::SplitFFT< T >::runScaledSwap ( const T *  re,
const T *  im,
const T *  gain,
size_t  mask,
const T *&  outRe,
const T *&  outIm 
)
inlinenoexcept

Transforms the spectrum product whose bin k is (im[k & mask] gain[k], re[k & mask] gain[k]), read straight from the arrays. Run on a product's swapped parts, a forward transform is its inverse with the parts swapped back on the way out, so this is a filter's multiply and inverse in one go. The product is never stored, so a build that contracts multiply-adds may fuse it into the first pass: one rounding fewer than writing it to the input buffers first and calling run().

Parameters
reReal parts, mask + 1 bins (may be this engine's last output).
imImaginary parts, mask + 1 bins.
gainN real gains.
maskOne less than a power of two that divides N: the spectrum repeats every mask + 1 bins (N - 1 for none).
outReReceives the pointer to the N output real parts.
outImReceives the pointer to the N output imaginary parts.

Definition at line 643 of file FFT.h.

◆ runScaledSwapFolded()

template<typename T >
void dspark::detail::fft::SplitFFT< T >::runScaledSwapFolded ( const T *  re,
const T *  im,
const T *  gain,
size_t  fold,
const T *&  outRe,
const T *&  outIm 
)
inlinenoexcept

runScaledSwap() of a spectrum fold times this engine's size, folded: bin k sums the products of bins k + f N, f < fold. The result is the inverse of the product at every fold-th sample, exact when the product holds nothing the fold aliases (a filter whose stopband starts at the decimated Nyquist).

Parameters
reReal parts, fold * N bins (outside this engine's buffers).
imImaginary parts, fold * N bins.
gainfold * N real gains.
foldDecimation factor, at least 1.
outReReceives the pointer to the N output real parts.
outImReceives the pointer to the N output imaginary parts.

Definition at line 680 of file FFT.h.

◆ runTo()

template<typename T >
void dspark::detail::fft::SplitFFT< T >::runTo ( T *  out,
T  scaleRe,
T  scaleIm 
)
inlinenoexcept

Transforms the input buffers and writes interleaved output directly.

Parameters
outReceives N interleaved complex values.
scaleReFactor applied to the real parts.
scaleImFactor applied to the imaginary parts.

Definition at line 701 of file FFT.h.

◆ runToStep()

template<typename T >
void dspark::detail::fft::SplitFFT< T >::runToStep ( size_t  step,
T *  out,
T  scaleRe,
T  scaleIm 
)
inlinenoexcept

Runs one step of runTo(): step s below runToStepCount() - 1 is pass s, the last step the closing pass into out. All steps in order, with nothing else run in between, equal runTo() bit for bit (the passes alternate between the two work buffers, so the buffer a step reads follows from its index). Step 0 chooses the kernel set and the later steps keep it, as runTo() does.

Parameters
stepStep index, 0 .. runToStepCount() - 1.
outReceives N interleaved complex values (last step only).
scaleReFactor applied to the real parts (last step only).
scaleImFactor applied to the imaginary parts (last step only).

Definition at line 759 of file FFT.h.

◆ runToStepCount()

template<typename T >
size_t dspark::detail::fft::SplitFFT< T >::runToStepCount ( ) const
inlinenoexcept

Steps of runTo() as runToStep() splits it: one per pass before the closing one, then the closing pass.

Definition at line 745 of file FFT.h.

◆ size()

template<typename T >
size_t dspark::detail::fft::SplitFFT< T >::size ( ) const
inlinenoexcept

Definition at line 547 of file FFT.h.

Member Data Documentation

◆ kAllocationOverhead

template<typename T >
constexpr size_t dspark::detail::fft::SplitFFT< T >::kAllocationOverhead = 64
staticconstexpr

Room a standard library may add to one allocation request for its own alignment bookkeeping (one library requests 39 more bytes for every vector of 4 KiB or more).

Definition at line 528 of file FFT.h.


The documentation for this class was generated from the following file: