Signalsmith Audio's DSP Library  1.6.0
Useful C++ classes/templates for audio effects
Static Methods | Methods
signalsmith::spectral::WindowedFFT< Sample > Class Template Reference

#include <spectral.h>

Detailed Description

template<typename Sample>
class signalsmith::spectral::WindowedFFT< Sample >

An FFT with built-in windowing and round-trip scaling.

This uses a Modified Real FFT, which applies half-bin shift before the transform. The result therefore has N/2 bins, centred at the frequencies: (i + 0.5)/N.

This avoids the awkward (real-valued) bands for DC-offset and Nyquist.

Static Methods

static int fastSizeAbove (int size, int divisor=1)
 Returns a fast FFT size <= size More...
 
static int fastSizeBelow (int size, int divisor=1)
 Returns a fast FFT size >= size More...
 

Methods

 WindowedFFT (int size, int rotateSamples=0)
 
template<class WindowFn >
 WindowedFFT (int size, WindowFn fn, Sample windowOffset=0.5, int rotateSamples=0)
 
std::vector< Sample > & setSizeWindow (int size, int rotateSamples=0)
 Sets the size, returning the window for modification (initially all 1s) More...
 
template<class WindowFn >
void setSize (int size, WindowFn fn, Sample windowOffset=0.5, int rotateSamples=0)
 Sets the FFT size, with a user-defined functor for the window. More...
 
void setSize (int size, int rotateSamples=0)
 Sets the size (using the default Blackman-Harris window) More...
 
const std::vector< Sample > & window () const
 
int size () const
 
template<class Input , class Output >
void fft (Input &&input, Output &&output)
 Performs an FFT (with windowing) More...
 
template<class Input , class Output >
void fftRaw (Input &&input, Output &&output)
 Performs an FFT (no windowing or rotation) More...
 
template<class Input , class Output >
void ifft (Input &&input, Output &&output)
 Inverse FFT, with windowing and 1/N scaling. More...
 
template<class Input , class Output >
void ifftRaw (Input &&input, Output &&output)
 Performs an IFFT (no windowing or rotation) More...
 

Method Details

◆ fastSizeAbove()

template<typename Sample >
static int signalsmith::spectral::WindowedFFT< Sample >::fastSizeAbove ( int  size,
int  divisor = 1 
)
inlinestatic

Returns a fast FFT size <= size

◆ fastSizeBelow()

template<typename Sample >
static int signalsmith::spectral::WindowedFFT< Sample >::fastSizeBelow ( int  size,
int  divisor = 1 
)
inlinestatic

Returns a fast FFT size >= size

◆ fft()

template<typename Sample >
template<class Input , class Output >
void signalsmith::spectral::WindowedFFT< Sample >::fft ( Input &&  input,
Output &&  output 
)
inline

Performs an FFT (with windowing)

◆ fftRaw()

template<typename Sample >
template<class Input , class Output >
void signalsmith::spectral::WindowedFFT< Sample >::fftRaw ( Input &&  input,
Output &&  output 
)
inline

Performs an FFT (no windowing or rotation)

◆ ifft()

template<typename Sample >
template<class Input , class Output >
void signalsmith::spectral::WindowedFFT< Sample >::ifft ( Input &&  input,
Output &&  output 
)
inline

Inverse FFT, with windowing and 1/N scaling.

◆ ifftRaw()

template<typename Sample >
template<class Input , class Output >
void signalsmith::spectral::WindowedFFT< Sample >::ifftRaw ( Input &&  input,
Output &&  output 
)
inline

Performs an IFFT (no windowing or rotation)

◆ setSize() [1/2]

template<typename Sample >
void signalsmith::spectral::WindowedFFT< Sample >::setSize ( int  size,
int  rotateSamples = 0 
)
inline

Sets the size (using the default Blackman-Harris window)

◆ setSize() [2/2]

template<typename Sample >
template<class WindowFn >
void signalsmith::spectral::WindowedFFT< Sample >::setSize ( int  size,
WindowFn  fn,
Sample  windowOffset = 0.5,
int  rotateSamples = 0 
)
inline

Sets the FFT size, with a user-defined functor for the window.

◆ setSizeWindow()

template<typename Sample >
std::vector<Sample>& signalsmith::spectral::WindowedFFT< Sample >::setSizeWindow ( int  size,
int  rotateSamples = 0 
)
inline

Sets the size, returning the window for modification (initially all 1s)