Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::signal::HalfBandIirStageT< SampleType > Class Template Reference

Fixed-storage polyphase half-band stage that filters whole blocks: the engine behind HalfBandUpsampler2xT, HalfBandDownsampler2xT, and the oversampler's polyphase lane. More...

#include <halfband_iir.hpp>

Public Types

using State = std::conditional_t<(sizeof(SampleType) < sizeof(double)), double, SampleType>
 Coefficients and recurrence state are kept in double even for a float stage.

Public Member Functions

void configure (const HalfBandIirDesign &design) noexcept
void reset () noexcept
std::size_t coefficient_count () const noexcept
std::size_t sections_a () const noexcept
std::size_t sections_b () const noexcept
bool configured () const noexcept
 True when a valid design is loaded; an unconfigured stage emits silence.
void upsample (const SampleType *input, SampleType *output, std::size_t n) noexcept
 n input samples -> 2n output samples.
void downsample (const SampleType *input, SampleType *output, std::size_t n) noexcept
 2n input samples -> n output samples. output may alias input.

Static Public Attributes

static constexpr std::size_t kMaxPath = kHalfBandIirMaxCoefficients / 2

Detailed Description

template<typename SampleType = float>
class pulp::signal::HalfBandIirStageT< SampleType >

Fixed-storage polyphase half-band stage that filters whole blocks: the engine behind HalfBandUpsampler2xT, HalfBandDownsampler2xT, and the oversampler's polyphase lane.

configure() takes a HalfBandIirDesign; an invalid (empty) design leaves the stage emitting silence.

RT contract: no member allocates; configure() and reset() are control-thread setup, upsample() / downsample() are realtime safe.

The per-path section counts are template parameters inside the kernels, so the coefficients and recurrence state live in registers for the length of a block and nothing is zeroed or re-loaded per sample. Each section is evaluated as y = a*x + x1 - a*y1, which leaves a single fused multiply-add on the y1 recurrence. Up and down directions keep separate state.

Member Typedef Documentation

◆ State

template<typename SampleType = float>
using pulp::signal::HalfBandIirStageT< SampleType >::State = std::conditional_t<(sizeof(SampleType) < sizeof(double)), double, SampleType>

Coefficients and recurrence state are kept in double even for a float stage.

The kernel is scalar and bound by the recurrence latency, and on current cores a scalar double fused multiply-add has the same latency and throughput as a float one, so the wider state is free; what it buys is a round trip whose rounding floor is the float output's own (about -153 dB) rather than the accumulated rounding of every section (about -132 to -139 dB in float). Extended-precision state is the classic remedy for roundoff noise accumulating through cascaded recursive sections (L. B. Jackson, "Roundoff-noise analysis for fixed-point digital filters realized in cascade or parallel form", IEEE Trans. Audio Electroacoust. 18(2), 1970; N. J. Higham, "Accuracy and Stability of Numerical Algorithms", 2nd ed., SIAM 2002, ch. 3).

Member Function Documentation

◆ coefficient_count()

template<typename SampleType = float>
std::size_t pulp::signal::HalfBandIirStageT< SampleType >::coefficient_count ( ) const
inlinenoexcept

◆ configure()

template<typename SampleType = float>
void pulp::signal::HalfBandIirStageT< SampleType >::configure ( const HalfBandIirDesign & design)
inlinenoexcept

◆ configured()

template<typename SampleType = float>
bool pulp::signal::HalfBandIirStageT< SampleType >::configured ( ) const
inlinenoexcept

True when a valid design is loaded; an unconfigured stage emits silence.

◆ downsample()

template<typename SampleType = float>
void pulp::signal::HalfBandIirStageT< SampleType >::downsample ( const SampleType * input,
SampleType * output,
std::size_t n )
inlinenoexcept

2n input samples -> n output samples. output may alias input.

◆ reset()

template<typename SampleType = float>
void pulp::signal::HalfBandIirStageT< SampleType >::reset ( )
inlinenoexcept

◆ sections_a()

template<typename SampleType = float>
std::size_t pulp::signal::HalfBandIirStageT< SampleType >::sections_a ( ) const
inlinenoexcept

◆ sections_b()

template<typename SampleType = float>
std::size_t pulp::signal::HalfBandIirStageT< SampleType >::sections_b ( ) const
inlinenoexcept

◆ upsample()

template<typename SampleType = float>
void pulp::signal::HalfBandIirStageT< SampleType >::upsample ( const SampleType * input,
SampleType * output,
std::size_t n )
inlinenoexcept

n input samples -> 2n output samples.

output must not overlap input.

Member Data Documentation

◆ kMaxPath

template<typename SampleType = float>
std::size_t pulp::signal::HalfBandIirStageT< SampleType >::kMaxPath = kHalfBandIirMaxCoefficients / 2
staticconstexpr

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