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

One second-order section in normalized ladder form, per channel. More...

#include <NormalizedLadder.h>

Classes

struct  Coeffs
 The two rotations and the three taps (the identity by default). More...
 

Public Member Functions

void setCoeffs (const BiquadCoeffs &b) noexcept
 Makes a biquad's response the section's own from the next sample; ends a ramp.
 
void setLadder (const Coeffs &l) noexcept
 Sets rotations and taps directly from the next sample; ends a ramp.
 
void rampCoeffs (const BiquadCoeffs &target, int samples) noexcept
 Moves the rotations and the taps linearly to those of a biquad.
 
Coeffs getLadder () const noexcept
 Rotations and taps in use now (mid ramp, where the ramp is).
 
bool isRamping () const noexcept
 Whether the coefficients are moving.
 
void reset () noexcept
 Clears the memory of every channel. Coefficients and ramp are kept.
 
double getStateEnergy (int channel) const noexcept
 The energy in a channel's memory, x1^2 + x2^2 (it only falls with no input).
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Runs a block through the section, in place.
 
double processSample (double input, int channel) noexcept
 One sample of one channel, in double, with the coefficients as they are.
 
void processSegment (double *data, int numSamples, int channel) noexcept
 Runs one channel's samples through the section, in double and in place, walking the ramp from where it stands without moving it on.
 
void advanceRamp (int samples) noexcept
 Moves the ramp on by a number of samples (for processSample() callers).
 

Static Public Member Functions

static Coeffs fromBiquad (const BiquadCoeffs &b) noexcept
 The ladder of a biquad.
 
static BiquadCoeffs toBiquad (const Coeffs &l) noexcept
 The biquad a ladder realises (for curves and checks).
 

Detailed Description

template<typename T, int MaxChannels = 8>
class dspark::NormalizedLadder< T, MaxChannels >

One second-order section in normalized ladder form, per channel.

Template Parameters
TSample type of the buffers (float or double); the recursion and its memory are double either way.
MaxChannelsLargest number of channels.

Definition at line 71 of file NormalizedLadder.h.

Member Function Documentation

◆ advanceRamp()

template<typename T , int MaxChannels = 8>
void dspark::NormalizedLadder< T, MaxChannels >::advanceRamp ( int  samples)
inlinenoexcept

Moves the ramp on by a number of samples (for processSample() callers).

Parameters
samplesSamples gone by; a ramp with fewer left lands on its target.

Definition at line 275 of file NormalizedLadder.h.

◆ fromBiquad()

template<typename T , int MaxChannels = 8>
static Coeffs dspark::NormalizedLadder< T, MaxChannels >::fromBiquad ( const BiquadCoeffs &  b)
inlinestaticnoexcept

The ladder of a biquad.

A set whose poles are on or outside the unit circle has a reflection coefficient of magnitude one or more; it is brought just inside, so the section stays passive whatever it is given.

Parameters
bNormalised biquad coefficients.
Returns
Rotations and taps with the same transfer function.

Definition at line 92 of file NormalizedLadder.h.

◆ getLadder()

template<typename T , int MaxChannels = 8>
Coeffs dspark::NormalizedLadder< T, MaxChannels >::getLadder ( ) const
inlinenoexcept

Rotations and taps in use now (mid ramp, where the ramp is).

Definition at line 160 of file NormalizedLadder.h.

◆ getStateEnergy()

template<typename T , int MaxChannels = 8>
double dspark::NormalizedLadder< T, MaxChannels >::getStateEnergy ( int  channel) const
inlinenoexcept

The energy in a channel's memory, x1^2 + x2^2 (it only falls with no input).

Definition at line 172 of file NormalizedLadder.h.

◆ isRamping()

template<typename T , int MaxChannels = 8>
bool dspark::NormalizedLadder< T, MaxChannels >::isRamping ( ) const
inlinenoexcept

Whether the coefficients are moving.

Definition at line 163 of file NormalizedLadder.h.

◆ processBlock()

template<typename T , int MaxChannels = 8>
void dspark::NormalizedLadder< T, MaxChannels >::processBlock ( AudioBufferView< T >  buffer)
inlinenoexcept

Runs a block through the section, in place.

Channels beyond MaxChannels are left untouched; every channel walks the same ramp. A memory a non-finite sample has reached is cleared at the end of the block.

Parameters
bufferAudio to filter.

Definition at line 187 of file NormalizedLadder.h.

◆ processSample()

template<typename T , int MaxChannels = 8>
double dspark::NormalizedLadder< T, MaxChannels >::processSample ( double  input,
int  channel 
)
inlinenoexcept

One sample of one channel, in double, with the coefficients as they are.

Ramps advance in processBlock(), or by the caller's advanceRamp() once per frame.

Precondition
channel in [0, MaxChannels).

Definition at line 228 of file NormalizedLadder.h.

◆ processSegment()

template<typename T , int MaxChannels = 8>
void dspark::NormalizedLadder< T, MaxChannels >::processSegment ( double *  data,
int  numSamples,
int  channel 
)
inlinenoexcept

Runs one channel's samples through the section, in double and in place, walking the ramp from where it stands without moving it on.

For owners that run their channels one after another over the same frames: every channel walks the same coefficients, and advanceRamp() by the same count, once all of them have run, moves the ramp on (the result is processBlock()'s, to the bit).

Parameters
dataSamples of the channel, filtered in place.
numSamplesNumber of samples.
channelChannel whose memory the samples run through.
Precondition
channel in [0, MaxChannels).

Definition at line 249 of file NormalizedLadder.h.

◆ rampCoeffs()

template<typename T , int MaxChannels = 8>
void dspark::NormalizedLadder< T, MaxChannels >::rampCoeffs ( const BiquadCoeffs &  target,
int  samples 
)
inlinenoexcept

Moves the rotations and the taps linearly to those of a biquad.

The ramp starts from the values in use and lands exactly on the target after samples samples. Along it each rotation stays on or inside the unit circle: the section never adds energy to its memory.

Parameters
targetResponse to arrive at.
samplesLength of the ramp in samples; 0 or less sets it at once.

Definition at line 147 of file NormalizedLadder.h.

◆ reset()

template<typename T , int MaxChannels = 8>
void dspark::NormalizedLadder< T, MaxChannels >::reset ( )
inlinenoexcept

Clears the memory of every channel. Coefficients and ramp are kept.

Definition at line 166 of file NormalizedLadder.h.

◆ setCoeffs()

template<typename T , int MaxChannels = 8>
void dspark::NormalizedLadder< T, MaxChannels >::setCoeffs ( const BiquadCoeffs &  b)
inlinenoexcept

Makes a biquad's response the section's own from the next sample; ends a ramp.

Definition at line 127 of file NormalizedLadder.h.

◆ setLadder()

template<typename T , int MaxChannels = 8>
void dspark::NormalizedLadder< T, MaxChannels >::setLadder ( const Coeffs &  l)
inlinenoexcept

Sets rotations and taps directly from the next sample; ends a ramp.

Definition at line 130 of file NormalizedLadder.h.

◆ toBiquad()

template<typename T , int MaxChannels = 8>
static BiquadCoeffs dspark::NormalizedLadder< T, MaxChannels >::toBiquad ( const Coeffs &  l)
inlinestaticnoexcept

The biquad a ladder realises (for curves and checks).

Parameters
lRotations and taps.
Returns
Normalised biquad coefficients.

Definition at line 115 of file NormalizedLadder.h.


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