|
DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
|
A whole filter of order N as one normalized ladder (Gray and Markel), designed from its polynomials, without roots. More...
#include <NormalizedLadder.h>
Classes | |
| struct | Coeffs |
| The ladder's rotations and taps. More... | |
Public Member Functions | |
| bool | setCoeffs (const double *b, const double *a) noexcept |
| Takes a filter b(z) / a(z) at once; false (nothing changes) if it is not stable. | |
| bool | rampCoeffs (const double *b, const double *a, int samples) noexcept |
Moves every rotation and tap linearly to a filter's over samples; false if it is not stable. | |
| Coeffs | getLadder () const noexcept |
| bool | isRamping () const noexcept |
| void | reset () noexcept |
| Clears the memory of every channel. | |
| double | getStateEnergy (int channel) const noexcept |
| The energy of a channel's memory (the sum of the squares of its states). | |
| void | processBlock (AudioBufferView< T > buffer) noexcept |
| Runs a block, in place; a ramp moves on by its samples. Channels beyond MaxChannels are left untouched. | |
| double | processSample (double input, int channel) noexcept |
| One sample of one channel, in double, with the coefficients as they are (a ramp moves on with advanceRamp()). | |
| void | advanceRamp (int samples) noexcept |
| Moves a ramp on by a number of samples (for processSample() callers). | |
Static Public Member Functions | |
| static bool | design (const double *b, const double *a, Coeffs &out) noexcept |
| The ladder of a digital filter b(z) / a(z), each Order + 1 coefficients from z^0 (a[0] scales both). | |
A whole filter of order N as one normalized ladder (Gray and Markel), designed from its polynomials, without roots.
The denominator 1 + a1 z^-1 + ... + aN z^-N is stepped down to its reflection coefficients: k_m is the last coefficient of the polynomial of order m, and the polynomial of order m - 1 is (A_m - k_m B_m) / (1 - k_m^2), where B_m is A_m reversed (z^-m A_m(1/z)). Each k_m is a plane rotation (s = k_m, c = sqrt(1 - k_m^2)); the input enters at the top and runs down through the rotations:
The signal g_m is (c_(m+1) ... c_N) B_m / A, so the taps of a numerator come down from the top: v_m is what is left of it at z^-m over the product of the c above m, and v_m times that product times B_m comes off what is left. The filter is stable when every |k_m| < 1, which the design checks.
As the second-order NormalizedLadder, the step from the input and the memory to the memory and g_N is orthogonal, so with no input the memory can only lose energy whatever the coefficients do: a filter of order five whose knob moves at audio rate keeps bounded. A ramp moves every c, s and v linearly; the pairs (c, s) stay on or inside the unit circle on the way. FilterDesign::bilinearPolynomial() takes an analog network of any order (its numerator and denominator as polynomials in s) to the digital polynomials this class takes, so a network from components needs no factoring.
Threading: owner-managed, like NormalizedLadder.
| T | Sample type of the buffers (float or double); the recursion and its memory are double either way. |
| Order | Order of the filter, 1 to 16. |
| MaxChannels | Largest number of channels. |
Definition at line 361 of file NormalizedLadder.h.
|
inlinenoexcept |
Moves a ramp on by a number of samples (for processSample() callers).
Definition at line 527 of file NormalizedLadder.h.
|
inlinestaticnoexcept |
The ladder of a digital filter b(z) / a(z), each Order + 1 coefficients from z^0 (a[0] scales both).
out untouched, when the denominator is not stable (a reflection coefficient of 1 or more) or a[0] is 0. Definition at line 380 of file NormalizedLadder.h.
|
inlinenoexcept |
Definition at line 458 of file NormalizedLadder.h.
|
inlinenoexcept |
The energy of a channel's memory (the sum of the squares of its states).
Definition at line 468 of file NormalizedLadder.h.
|
inlinenoexcept |
Definition at line 459 of file NormalizedLadder.h.
|
inlinenoexcept |
Runs a block, in place; a ramp moves on by its samples. Channels beyond MaxChannels are left untouched.
Definition at line 477 of file NormalizedLadder.h.
|
inlinenoexcept |
One sample of one channel, in double, with the coefficients as they are (a ramp moves on with advanceRamp()).
Definition at line 520 of file NormalizedLadder.h.
|
inlinenoexcept |
Moves every rotation and tap linearly to a filter's over samples; false if it is not stable.
Definition at line 435 of file NormalizedLadder.h.
|
inlinenoexcept |
Clears the memory of every channel.
Definition at line 462 of file NormalizedLadder.h.
|
inlinenoexcept |
Takes a filter b(z) / a(z) at once; false (nothing changes) if it is not stable.
Definition at line 425 of file NormalizedLadder.h.