|
DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
|
Six bands of cuts, bells, shelves and tilts over the key of a dynamics processor. More...
#include <KeyEqualizer.h>
Classes | |
| struct | Band |
| The settings of one band. More... | |
| struct | Response |
| The sections of a set of bands, to draw the curve they make. More... | |
Public Types | |
| enum class | Shape { Off , LowCut , HighCut , Bell , LowShelf , HighShelf , Tilt } |
| What a band does to the key. More... | |
| enum class | Placement { Stereo , Mid , Side } |
| The part of a two-channel key a band acts on (see processFrame()). More... | |
Public Member Functions | |
| void | prepare (double sampleRate) noexcept |
| Prepares the equalizer for a sample rate and clears its memory. | |
| void | reset () noexcept |
| Clears the memory of the filters (settings and glides are kept). | |
| void | setBand (int band, const Band &settings) noexcept |
| Publishes the settings of a band. | |
| Band | getBand (int band) const noexcept |
| The published settings of a band (a band out of range reads as Off). | |
| bool | hasBands () const noexcept |
| Whether any published band is in the path. | |
| Response | getResponse (Placement part=Placement::Stereo) const noexcept |
| The sections of the published bands, designed as the audio thread designs them, for a display. | |
| void | setLoudnessCompensation (bool on) noexcept |
| Keeps the loudness (off by default): the bands' change of the K-weighted level of pink noise (as BS.1770 hears it) is taken back by a gain, which moves in 50 ms (as advance() goes) when the bands change. It reads every band, wherever it is placed. | |
| bool | getLoudnessCompensation () const noexcept |
| double | getCompensationDb () const noexcept |
| void | writeState (StateWriter &w, const char *prefix) const |
| Writes the bands under keys that start with a prefix ("<prefix><band>.shape", ".freq", ".gain", ".q", ".slope", ".place"), and "<prefix>loudness". | |
| void | readState (const StateReader &r, const char *prefix) noexcept |
| Reads the bands writeState() wrote (a band that is missing reads as Off, a placement that is missing as Stereo). | |
| bool | sync () noexcept |
| Takes the settings published since the last call. | |
| bool | isActive () const noexcept |
| Whether any section is in the path: processSample() and processFrame() do nothing otherwise. | |
| bool | isPlaced () const noexcept |
| Whether a band in the path is placed on the middle or on the sides: only processFrame() gives those their part. | |
| int | getStretch () const noexcept |
| Frames between two designs of a band on the move: advance() at least this often for a glide to be followed step by step. | |
| T | processSample (T input, int channel) noexcept |
| One sample of one channel of the key through the equalizer. | |
| void | processFrame (T *frame, int channels) noexcept |
| One frame of the key, every channel of it, in place. | |
| void | advance (int samples) noexcept |
| Moves the equalizer on in time: the coefficients between two designs, the bands on the move to their next design, and a change of design to its end. | |
Static Public Attributes | |
| static constexpr int | kBands = 6 |
| Bands of the equalizer. | |
| static constexpr int | kBandSections = 5 |
| Most sections one band takes (a 48 dB per octave cut). | |
| static constexpr int | kSections = kBands * kBandSections |
| static constexpr double | kRampSeconds = 0.02 |
| Time a new setting takes to arrive. | |
| static constexpr double | kStretchSeconds = 1.0 / 1500.0 |
| A band on the move is designed again this often. | |
Six bands of cuts, bells, shelves and tilts over the key of a dynamics processor.
| T | Sample type (float or double). The filters run in double either way. |
| MaxChannels | Largest number of key channels. |
Definition at line 89 of file KeyEqualizer.h.
|
strong |
The part of a two-channel key a band acts on (see processFrame()).
| Enumerator | |
|---|---|
| Stereo | Both channels (default). |
| Mid | The middle of the pair, (L + R) / 2, alone. |
| Side | The sides of the pair, (L - R) / 2, alone. |
Definition at line 111 of file KeyEqualizer.h.
|
strong |
What a band does to the key.
Definition at line 99 of file KeyEqualizer.h.
|
inlinenoexcept |
Moves the equalizer on in time: the coefficients between two designs, the bands on the move to their next design, and a change of design to its end.
| samples | Frames gone by since the last call. |
Definition at line 444 of file KeyEqualizer.h.
|
inlinenoexcept |
The published settings of a band (a band out of range reads as Off).
Definition at line 234 of file KeyEqualizer.h.
|
inlinenoexcept |
Definition at line 297 of file KeyEqualizer.h.
|
inlinenoexcept |
Definition at line 294 of file KeyEqualizer.h.
|
inlinenoexcept |
The sections of the published bands, designed as the audio thread designs them, for a display.
A design costs a few microseconds per section: build one Response when the settings change and read every frequency from it.
| part | Stereo (default): every band, wherever it is placed. Mid or Side: what that part of a two-channel key goes through, the bands on both channels and the ones placed on it. |
Definition at line 267 of file KeyEqualizer.h.
|
inlinenoexcept |
Frames between two designs of a band on the move: advance() at least this often for a glide to be followed step by step.
Definition at line 382 of file KeyEqualizer.h.
|
inlinenoexcept |
Whether any published band is in the path.
Definition at line 249 of file KeyEqualizer.h.
|
inlinenoexcept |
Whether any section is in the path: processSample() and processFrame() do nothing otherwise.
Definition at line 374 of file KeyEqualizer.h.
|
inlinenoexcept |
Whether a band in the path is placed on the middle or on the sides: only processFrame() gives those their part.
Definition at line 378 of file KeyEqualizer.h.
|
inlinenoexcept |
Prepares the equalizer for a sample rate and clears its memory.
Allocates the two banks the first time. The published bands are kept and taken at once (with no glide and no fade) by the next sync(). An invalid rate is ignored.
| sampleRate | Sample rate in hertz. |
Definition at line 158 of file KeyEqualizer.h.
|
inlinenoexcept |
One frame of the key, every channel of it, in place.
With two channels and a band placed on the middle or on the sides, the frame is taken to its middle (L + R) / 2 and its sides (L - R) / 2, each goes through the bands on both channels and the bands placed on it, and the pair comes back as their sum and their difference. With no band placed there is no conversion: each channel goes through every band, exactly as through processSample(). A single channel is its own middle and has no sides: the bands placed on the sides leave it alone. With more than two channels every band acts on every channel.
| frame | The key of each channel, replaced in place. |
| channels | Channels in the frame (those over MaxChannels are left alone). |
Definition at line 418 of file KeyEqualizer.h.
|
inlinenoexcept |
One sample of one channel of the key through the equalizer.
Every band acts on the channel, wherever it is placed: a caller that has the key one channel at a time has no middle and no sides to give.
| input | Key sample. |
| channel | Channel index. |
Definition at line 395 of file KeyEqualizer.h.
|
inlinenoexcept |
Reads the bands writeState() wrote (a band that is missing reads as Off, a placement that is missing as Stereo).
Definition at line 329 of file KeyEqualizer.h.
|
inlinenoexcept |
Clears the memory of the filters (settings and glides are kept).
A change of design in flight ends at once: the bank that was coming in is the one that stays.
Definition at line 193 of file KeyEqualizer.h.
|
inlinenoexcept |
Publishes the settings of a band.
Values out of range are brought into it; a field that is not finite keeps what it had. The audio thread takes the change in its next sync().
| band | Band index in [0, kBands); others are ignored. |
| settings | The band. |
Definition at line 214 of file KeyEqualizer.h.
|
inlinenoexcept |
Keeps the loudness (off by default): the bands' change of the K-weighted level of pink noise (as BS.1770 hears it) is taken back by a gain, which moves in 50 ms (as advance() goes) when the bands change. It reads every band, wherever it is placed.
Definition at line 287 of file KeyEqualizer.h.
|
inlinenoexcept |
Takes the settings published since the last call.
Definition at line 361 of file KeyEqualizer.h.
|
inline |
Writes the bands under keys that start with a prefix ("<prefix><band>.shape", ".freq", ".gain", ".q", ".slope", ".place"), and "<prefix>loudness".
Definition at line 304 of file KeyEqualizer.h.
|
staticconstexpr |
Bands of the equalizer.
Definition at line 92 of file KeyEqualizer.h.
|
staticconstexpr |
Most sections one band takes (a 48 dB per octave cut).
Definition at line 93 of file KeyEqualizer.h.
|
staticconstexpr |
Time a new setting takes to arrive.
Definition at line 95 of file KeyEqualizer.h.
|
staticconstexpr |
Definition at line 94 of file KeyEqualizer.h.
|
staticconstexpr |
A band on the move is designed again this often.
Definition at line 96 of file KeyEqualizer.h.