DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::WindowFunctions< T > Struct Template Reference

Static utility generating window functions for DSP analysis/synthesis. More...

#include <WindowFunctions.h>

Public Member Functions

 WindowFunctions ()=delete
 

Static Public Member Functions

static void rectangular (T *output, int size) noexcept
 Rectangular window (no windowing – all ones).
 
static void triangular (T *output, int size, bool periodic=true) noexcept
 Triangular (Bartlett) window.
 
static void hann (T *output, int size, bool periodic=true) noexcept
 Hann (raised cosine) window.
 
static void hamming (T *output, int size, bool periodic=true) noexcept
 Hamming window.
 
static void blackman (T *output, int size, bool periodic=true) noexcept
 Blackman window.
 
static void blackmanHarris (T *output, int size, bool periodic=true) noexcept
 Blackman-Harris window (4-term, -92 dB side lobes).
 
static void flatTop (T *output, int size, bool periodic=true) noexcept
 Flat-top window (amplitude-accurate: scallop loss < 0.01 dB).
 
static void kaiser (T *output, int size, T beta, bool periodic=true) noexcept
 Kaiser window with configurable shape parameter beta.
 
static void apply (T *signal, const T *window, int size) noexcept
 Applies a window to a signal buffer in-place.
 
static T coherentGain (const T *window, int size) noexcept
 Computes the coherent gain of a window (mean of its samples).
 
static T energyGain (const T *window, int size) noexcept
 Computes the energy gain (RMS) of a window.
 

Detailed Description

template<typename T>
struct dspark::WindowFunctions< T >

Static utility generating window functions for DSP analysis/synthesis.

All functions write size values into the output array. Valid size must be > 0. A size of 1 produces a unit impulse (1.0).

The periodic flag selects the divisor of the phase term: periodic = true (the default) generates DFT-periodic windows whose overlap-add properties hold exactly (use for STFT/WOLA processing); false generates symmetric windows that start and end on the same value (use for FIR filter design, where symmetry gives exact linear phase).

Template Parameters
TProcessing type (float or double).

Definition at line 59 of file WindowFunctions.h.

Constructor & Destructor Documentation

◆ WindowFunctions()

template<typename T >
dspark::WindowFunctions< T >::WindowFunctions ( )
delete

Member Function Documentation

◆ apply()

template<typename T >
static void dspark::WindowFunctions< T >::apply ( T *  signal,
const T *  window,
int  size 
)
inlinestaticnoexcept

Applies a window to a signal buffer in-place.

Real-time safe. No alignment requirements: the element-wise loop auto-vectorizes with unaligned loads (it is not a reduction).

Parameters
signalSignal buffer to window (modified in-place).
windowPre-computed window values.
sizeNumber of samples.

Definition at line 196 of file WindowFunctions.h.

◆ blackman()

template<typename T >
static void dspark::WindowFunctions< T >::blackman ( T *  output,
int  size,
bool  periodic = true 
)
inlinestaticnoexcept

Blackman window.

Parameters
outputDestination buffer.
sizeNumber of samples.
periodicTrue for WOLA (default), false for symmetric FIR design.

Definition at line 125 of file WindowFunctions.h.

◆ blackmanHarris()

template<typename T >
static void dspark::WindowFunctions< T >::blackmanHarris ( T *  output,
int  size,
bool  periodic = true 
)
inlinestaticnoexcept

Blackman-Harris window (4-term, -92 dB side lobes).

Parameters
outputDestination buffer.
sizeNumber of samples.
periodicTrue for WOLA (default), false for symmetric FIR design.

Definition at line 137 of file WindowFunctions.h.

◆ coherentGain()

template<typename T >
static T dspark::WindowFunctions< T >::coherentGain ( const T *  window,
int  size 
)
inlinestaticnoexcept

Computes the coherent gain of a window (mean of its samples).

Useful for recovering the true amplitude of a peak in a spectral bin after applying a windowing function. Accumulates in double so large windows do not lose calibration accuracy in float.

Parameters
windowPre-computed window values.
sizeNumber of samples.
Returns
Coherent gain (0.0 to 1.0).

Definition at line 218 of file WindowFunctions.h.

◆ energyGain()

template<typename T >
static T dspark::WindowFunctions< T >::energyGain ( const T *  window,
int  size 
)
inlinestaticnoexcept

Computes the energy gain (RMS) of a window.

Used for scaling the noise floor accurately when calculating Power Spectral Density (PSD). Accumulates in double.

Parameters
windowPre-computed window values.
sizeNumber of samples.
Returns
Energy gain (RMS multiplier).

Definition at line 240 of file WindowFunctions.h.

◆ flatTop()

template<typename T >
static void dspark::WindowFunctions< T >::flatTop ( T *  output,
int  size,
bool  periodic = true 
)
inlinestaticnoexcept

Flat-top window (amplitude-accurate: scallop loss < 0.01 dB).

Parameters
outputDestination buffer.
sizeNumber of samples.
periodicTrue for WOLA (default), false for symmetric FIR design.

Definition at line 150 of file WindowFunctions.h.

◆ hamming()

template<typename T >
static void dspark::WindowFunctions< T >::hamming ( T *  output,
int  size,
bool  periodic = true 
)
inlinestaticnoexcept

Hamming window.

Parameters
outputDestination buffer.
sizeNumber of samples.
periodicTrue for WOLA (default), false for symmetric FIR design.

Definition at line 113 of file WindowFunctions.h.

◆ hann()

template<typename T >
static void dspark::WindowFunctions< T >::hann ( T *  output,
int  size,
bool  periodic = true 
)
inlinestaticnoexcept

Hann (raised cosine) window.

Parameters
outputDestination buffer.
sizeNumber of samples.
periodicTrue for WOLA (default), false for symmetric FIR design.

Definition at line 101 of file WindowFunctions.h.

◆ kaiser()

template<typename T >
static void dspark::WindowFunctions< T >::kaiser ( T *  output,
int  size,
beta,
bool  periodic = true 
)
inlinestaticnoexcept

Kaiser window with configurable shape parameter beta.

Parameters
outputDestination buffer.
sizeNumber of samples.
betaShape parameter (typically 0.0 to 14.0; accurate to ~30).
periodicTrue for WOLA (default), false for symmetric FIR design.

Definition at line 165 of file WindowFunctions.h.

◆ rectangular()

template<typename T >
static void dspark::WindowFunctions< T >::rectangular ( T *  output,
int  size 
)
inlinestaticnoexcept

Rectangular window (no windowing – all ones).

Parameters
outputDestination buffer.
sizeNumber of samples.

Definition at line 69 of file WindowFunctions.h.

◆ triangular()

template<typename T >
static void dspark::WindowFunctions< T >::triangular ( T *  output,
int  size,
bool  periodic = true 
)
inlinestaticnoexcept

Triangular (Bartlett) window.

Parameters
outputDestination buffer.
sizeNumber of samples.
periodicTrue for WOLA (default), false for symmetric FIR design.

Definition at line 82 of file WindowFunctions.h.


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