|
DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
|
Up to MaxSections second-order sections in series, run in one pass. More...
#include <BiquadCascade.h>
Public Member Functions | |
| BiquadCascade () noexcept | |
| void | setNumSections (int count) noexcept |
| Sets how many sections the cascade has. | |
| int | getNumSections () const noexcept |
| Number of sections in the cascade. | |
| void | setCoeffs (int section, const BiquadCoeffs &c) noexcept |
| Makes a coefficient set a section's own from the next sample. | |
| void | rampCoeffs (int section, const BiquadCoeffs &target, int samples) noexcept |
| Moves a section's five coefficients linearly to a set. | |
| void | rampToBypass (int section, int samples) noexcept |
| Takes a section out of the path without a click. | |
| BiquadCoeffs | getCoeffs (int section) const noexcept |
| The coefficients a section is using now (mid ramp, where the ramp is). | |
| BiquadCoeffs | getTargetCoeffs (int section) const noexcept |
| The coefficients a section is heading to (its own when it is not ramping). | |
| bool | isRamping (int section) const noexcept |
| Whether a section's coefficients are moving. | |
| bool | isRamping () const noexcept |
| Whether any section's coefficients are moving. | |
| void | setSectionEnabled (int section, bool on) noexcept |
| Switches a section in or out of the path. | |
| bool | isSectionEnabled (int section) const noexcept |
| Whether a section is computed. | |
| void | reset () noexcept |
| Clears the memory of every node. Coefficients and ramps are kept. | |
| void | processBlock (AudioBufferView< T > buffer) noexcept |
| Runs a block through the cascade, in place. | |
| double | processSample (double input, int channel) noexcept |
| One sample of one channel through the cascade, in double. | |
| double | processSample (double input, int channel, std::uint64_t skip) noexcept |
| As processSample(), leaving some sections out for this call. | |
| void | turnPairMemory (int first, int second, bool back) noexcept |
| Rewrites the memory of a pair of channels as its middle and its sides, or back. | |
| void | advanceRamps (int samples) noexcept |
| Moves every ramp on by a number of samples (for processSample() callers). | |
Static Public Attributes | |
| static constexpr int | kGroup = 4 |
| Sections run together in one pass over the samples. | |
Up to MaxSections second-order sections in series, run in one pass.
| T | Sample type of the buffers (float or double). The recursion and its memory are double either way. |
| MaxSections | Largest number of sections. |
| MaxChannels | Largest number of channels. |
Definition at line 77 of file BiquadCascade.h.
|
inlinenoexcept |
Definition at line 83 of file BiquadCascade.h.
|
inlinenoexcept |
Moves every ramp on by a number of samples (for processSample() callers).
| samples | Samples gone by; a ramp with fewer left lands on its target. |
Definition at line 407 of file BiquadCascade.h.
|
inlinenoexcept |
The coefficients a section is using now (mid ramp, where the ramp is).
Definition at line 179 of file BiquadCascade.h.
|
inlinenoexcept |
Number of sections in the cascade.
Definition at line 111 of file BiquadCascade.h.
|
inlinenoexcept |
The coefficients a section is heading to (its own when it is not ramping).
Definition at line 185 of file BiquadCascade.h.
|
inlinenoexcept |
Whether any section's coefficients are moving.
Definition at line 197 of file BiquadCascade.h.
|
inlinenoexcept |
Whether a section's coefficients are moving.
Definition at line 191 of file BiquadCascade.h.
|
inlinenoexcept |
Whether a section is computed.
Definition at line 222 of file BiquadCascade.h.
|
inlinenoexcept |
Runs a block through the cascade, in place.
Channels beyond MaxChannels are left untouched. A memory that a non-finite sample has reached is cleared at the end of the block, so the channel recovers on the next one.
| buffer | Audio to filter. |
Definition at line 243 of file BiquadCascade.h.
|
inlinenoexcept |
One sample of one channel through the cascade, in double.
Uses the coefficients as they are: ramps advance in processBlock(), or by the caller's advanceRamps() once per frame.
| input | Input sample. |
| channel | Channel index. |
Definition at line 302 of file BiquadCascade.h.
|
inlinenoexcept |
As processSample(), leaving some sections out for this call.
A section whose bit is set in skip (bit s for section s) is not computed for this sample: what reaches it goes on to the next section and its own memory for the channel stays as it was. A cascade whose sections act on some channels only (an equalizer with bands for the middle or for the sides of a pair) passes each channel the mask of the sections that are not for it, the same mask on every sample.
| input | Input sample. |
| channel | Channel index. |
| skip | Sections to leave out, one bit each. |
Definition at line 342 of file BiquadCascade.h.
|
inlinenoexcept |
Moves a section's five coefficients linearly to a set.
The ramp starts from the coefficients in use (wherever a ramp in flight has brought them) and lands exactly on the target after samples samples.
| section | Section index in [0, MaxSections); others are ignored. |
| target | Coefficients to arrive at. |
| samples | Length of the ramp in samples; 0 or less sets the target at once. |
Definition at line 145 of file BiquadCascade.h.
|
inlinenoexcept |
Takes a section out of the path without a click.
Ramps the numerator of the section to its denominator: the poles and the memory keep running and what the section adds to its input dies away. Once the ramp is over the section passes its input (to rounding) and can be disabled.
| section | Section index. |
| samples | Length of the ramp in samples. |
Definition at line 172 of file BiquadCascade.h.
|
inlinenoexcept |
Clears the memory of every node. Coefficients and ramps are kept.
Definition at line 228 of file BiquadCascade.h.
|
inlinenoexcept |
Makes a coefficient set a section's own from the next sample.
Ends any ramp of the section. The state is signal, so the section carries on from what it has played; a large change is still a step in its response (use rampCoeffs() to glide).
| section | Section index in [0, MaxSections); others are ignored. |
| c | The coefficients. |
Definition at line 123 of file BiquadCascade.h.
|
inlinenoexcept |
Sets how many sections the cascade has.
Sections from the new count on are left out of the path as they are (their coefficients are kept); a section that comes into the path starts from the history of its input.
| count | Number of sections, clamped to [0, MaxSections]. |
Definition at line 99 of file BiquadCascade.h.
|
inlinenoexcept |
Switches a section in or out of the path.
A switch, not a fade: disable a section once it is transparent (after rampToBypass(), or while its coefficients are a bypassed() set) and it leaves without a trace. A disabled section is not computed. Enabled again it starts from the history of its input, so enabling a transparent section is silent too.
| section | Section index in [0, MaxSections); others are ignored. |
| on | True to compute the section. |
Definition at line 211 of file BiquadCascade.h.
|
inlinenoexcept |
Rewrites the memory of a pair of channels as its middle and its sides, or back.
The memory of the cascade is signal. A caller that has been giving the cascade the two channels of a pair and goes on to give it, in the same two channels, their half sum and their half difference can take the memory with it: every node of the first channel becomes the half sum of the two and every node of the second their half difference, and the sections carry on as if they had been fed that way all along (exact for the sections that run both channels, which share their coefficients). The way back is the sum and the difference.
| first | Channel that holds the left, or the middle. |
| second | Channel that holds the right, or the sides. |
| back | False: left and right become middle and sides. True: the other way. |
Definition at line 386 of file BiquadCascade.h.
|
staticconstexpr |
Sections run together in one pass over the samples.
Definition at line 81 of file BiquadCascade.h.