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

#include <biquad.hpp>

Public Types

enum class  Type {
  lowpass , highpass , bandpass , notch ,
  allpass , peaking , low_shelf , high_shelf
}
using Coefficients = BiquadCoefficientsT<SampleType>

Public Member Functions

 BiquadT ()=default
template<typename U>
void set_coefficients (const BiquadCoefficientsT< U > &c)
Coefficients coefficients () const
void set_coefficients (Type type, SampleType freq_hz, SampleType q, SampleType sample_rate, SampleType gain_db=SampleType{0})
SampleType process (SampleType input)
void process (SampleType *buffer, int num_samples)
void reset ()

Static Public Member Functions

static void process_stereo (BiquadT &left, BiquadT &right, SampleType *left_buffer, SampleType *right_buffer, std::size_t num_samples)
static void process_chain (BiquadT *sections, std::size_t count, SampleType *buffer, std::size_t num_samples) noexcept
 Run a chain of sections (a cascade: each section's output feeds the next) over a buffer in place.
static void process_chain_stereo (BiquadT *left, BiquadT *right, std::size_t count, SampleType *left_buffer, SampleType *right_buffer, std::size_t num_samples) noexcept
 process_chain() for two channels at once, each through its own chain of count sections, with the channels in the lanes of one vector.

Static Public Attributes

static constexpr std::size_t kChainSectionsPerPass = 16
 Sections process_chain() runs together in one sample-major pass.
static constexpr std::size_t kWideStateMaxSections = 4
 Longest float pass that runs the DF1 double-state form; its extra double arithmetic makes longer passes slower than the DF2T forms.
static constexpr std::size_t kStereoLaneMinSamples = 64
static constexpr double kFeedbackLastMaxPoleRadius = 0.995

Member Typedef Documentation

◆ Coefficients

template<typename SampleType = float>
using pulp::signal::BiquadT< SampleType >::Coefficients = BiquadCoefficientsT<SampleType>

Member Enumeration Documentation

◆ Type

template<typename SampleType = float>
enum class pulp::signal::BiquadT::Type
strong
Enumerator
lowpass 
highpass 
bandpass 
notch 
allpass 
peaking 
low_shelf 
high_shelf 

Constructor & Destructor Documentation

◆ BiquadT()

template<typename SampleType = float>
pulp::signal::BiquadT< SampleType >::BiquadT ( )
default

Member Function Documentation

◆ coefficients()

template<typename SampleType = float>
Coefficients pulp::signal::BiquadT< SampleType >::coefficients ( ) const
inline

◆ process() [1/2]

template<typename SampleType = float>
void pulp::signal::BiquadT< SampleType >::process ( SampleType * buffer,
int num_samples )
inline

◆ process() [2/2]

template<typename SampleType = float>
SampleType pulp::signal::BiquadT< SampleType >::process ( SampleType input)
inline

◆ process_chain()

template<typename SampleType = float>
void pulp::signal::BiquadT< SampleType >::process_chain ( BiquadT< SampleType > * sections,
std::size_t count,
SampleType * buffer,
std::size_t num_samples )
inlinestaticnoexcept

Run a chain of sections (a cascade: each section's output feeds the next) over a buffer in place.

Sample-major over up to kChainSectionsPerPass sections at a time: each sample runs through every section of the pass before the next sample starts, so the sections' recursions are independent dependency chains that execute concurrently instead of one section's whole buffer waiting on its own feedback latency (pipeline interleaving). Each pass picks the fastest form that meets the block path's accuracy contract (see process(SampleType*, int)); a single filter's block path is the one-section case of the same choice:

  • float passes of up to kWideStateMaxSections sections run the DF1 double-state form, with the signal kept in double between the sections of the pass;
  • longer passes, and every double pass, run the feedback-last DF2T order when every section's largest pole radius is at most kFeedbackLastMaxPoleRadius (its error then stays close to the sample path's), and the sample path's order otherwise, which is bit-identical to chaining the sections' per-sample process() while the state stays above the 1e-15 snap threshold. The DF1 and feedback-last forms are faster than the sample order; the DSP throughput benchmark tracks the figures.

◆ process_chain_stereo()

template<typename SampleType = float>
void pulp::signal::BiquadT< SampleType >::process_chain_stereo ( BiquadT< SampleType > * left,
BiquadT< SampleType > * right,
std::size_t count,
SampleType * left_buffer,
SampleType * right_buffer,
std::size_t num_samples )
inlinestaticnoexcept

process_chain() for two channels at once, each through its own chain of count sections, with the channels in the lanes of one vector.

Each channel's output is bit-identical to process_chain() on it alone. Compilers without vector lanes (simd::kHasVectorLanes) run the two chains in turn. Passing one chain as both channels runs the left buffer and then the right through it, as two process_chain() calls.

◆ process_stereo()

template<typename SampleType = float>
void pulp::signal::BiquadT< SampleType >::process_stereo ( BiquadT< SampleType > & left,
BiquadT< SampleType > & right,
SampleType * left_buffer,
SampleType * right_buffer,
std::size_t num_samples )
inlinestatic

◆ reset()

template<typename SampleType = float>
void pulp::signal::BiquadT< SampleType >::reset ( )
inline

◆ set_coefficients() [1/2]

template<typename SampleType = float>
template<typename U>
void pulp::signal::BiquadT< SampleType >::set_coefficients ( const BiquadCoefficientsT< U > & c)
inline

◆ set_coefficients() [2/2]

template<typename SampleType = float>
void pulp::signal::BiquadT< SampleType >::set_coefficients ( Type type,
SampleType freq_hz,
SampleType q,
SampleType sample_rate,
SampleType gain_db = SampleType{0} )
inline

Member Data Documentation

◆ kChainSectionsPerPass

template<typename SampleType = float>
std::size_t pulp::signal::BiquadT< SampleType >::kChainSectionsPerPass = 16
staticconstexpr

Sections process_chain() runs together in one sample-major pass.

A wider pass keeps more independent recursions in flight; splitting a cascade into narrower passes measured slower than one wide pass.

◆ kFeedbackLastMaxPoleRadius

template<typename SampleType = float>
double pulp::signal::BiquadT< SampleType >::kFeedbackLastMaxPoleRadius = 0.995
staticconstexpr

◆ kStereoLaneMinSamples

template<typename SampleType = float>
std::size_t pulp::signal::BiquadT< SampleType >::kStereoLaneMinSamples = 64
staticconstexpr

◆ kWideStateMaxSections

template<typename SampleType = float>
std::size_t pulp::signal::BiquadT< SampleType >::kWideStateMaxSections = 4
staticconstexpr

Longest float pass that runs the DF1 double-state form; its extra double arithmetic makes longer passes slower than the DF2T forms.


The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/signal/include/pulp/signal/biquad.hpp