|
DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
|
#include <Saturation.h>

Public Member Functions | |
| virtual | ~SaturationAlgorithm ()=default |
| virtual void | prepare (const AudioSpec &spec) noexcept=0 |
| Prepares the algorithm with the current audio specification. | |
| virtual void | reset () noexcept=0 |
| Resets internal states (filters, phase, memory). | |
| virtual void | update (T, T, const AudioSpec &) noexcept |
| Updates internal coefficients dependent on block-rate parameters. | |
| virtual Saturation< T >::Algorithm | getType () const noexcept=0 |
| Identifies the exact algorithm type for CRTP static dispatch. | |
| void | setAntialias (int order) noexcept |
| Antiderivative antialiasing order on the memoryless curves: 0 off, 1 first order (SoftClip/Tube/HardClip), 2 second order (SoftClip/Tube/HardClip/Wavefolder/Transformer/Exciter/Tape and every MultiStage stage from 2x, Bilbao et al. 2017). Order 2 delays every algorithm by the same number of processing samples (latchOrder()): the kernels delay by one and are padded to it, the others are delayed by all of it, so a crossfade between any two stays aligned. Default 0. | |
| void | latchOrder (int commonDelay=1) noexcept |
| Latches the order for the coming block (audio thread, before update()) and the common second-order delay in processing samples (1 to kMaxDelay; Saturation passes 1 at 1x, 4 at 2x and 3 from 4x). Entering order 2 arms every channel: its first sample seeds the kernel history and the delay line with the current input, so the delay is inserted as held samples instead of a step from stale history. The off and first-order paths keep no second-order history at all. | |
| int | order () const noexcept |
| The latched order (audio thread). | |
| int | commonDelay () const noexcept |
| The latched common second-order delay (processing samples). | |
| T | align (T y, int ch) noexcept |
| T | padKernel (T y, int ch) noexcept |
Static Public Attributes | |
| static constexpr int | kAaCh = 16 |
| static constexpr int | kMaxDelay = 4 |
Protected Member Functions | |
| bool | takeArm (int c) noexcept |
| T | delayBy (T y, int ch, int n) noexcept |
| T | delayHalfSample (T y, int ch) noexcept |
| void | resetAlign () noexcept |
Protected Attributes | |
| std::atomic< int > | antialias_ { 0 } |
| int | order_ = 0 |
| Latched order (audio thread). | |
| int | delay_ = 1 |
| Latched common second-order delay. | |
| unsigned | armMask_ = ~0u |
| Channels whose order-2 history must be seeded. | |
| unsigned | delayArm_ = ~0u |
| Channels whose delay line must be seeded. | |
| unsigned | halfArm_ = ~0u |
| Channels whose interpolator must be seeded. | |
| std::array< std::array< T, kMaxDelay >, kAaCh > | alignHold_ {} |
| std::array< std::array< T, 3 >, kAaCh > | halfHold_ {} |
Definition at line 82 of file Saturation.h.
|
virtualdefault |
|
inlinenoexcept |
Full common delay, for algorithms without a second-order kernel.
Definition at line 137 of file Saturation.h.
|
inlinenoexcept |
The latched common second-order delay (processing samples).
Definition at line 134 of file Saturation.h.
|
inlineprotectednoexcept |
Delays y by n (1 to kMaxDelay) samples on channel ch.
Definition at line 162 of file Saturation.h.
|
inlineprotectednoexcept |
Delays y by 1.5 samples on channel ch with a linear-phase 4-tap interpolator (its own history, seeded like the delay line). Coefficients -a, 0.5 + a, 0.5 + a, -a with a = 0.0824, the minimax choice for a flat response to 20 kHz at 96 kHz: within +0.10/-0.11 dB there, -0.54 dB at 24 kHz, a zero at half the rate.
Definition at line 185 of file Saturation.h.
|
pure virtualnoexcept |
Identifies the exact algorithm type for CRTP static dispatch.
Implemented in dspark::detail::TanhAlgorithm< T >, dspark::detail::TubeAlgorithm< T >, dspark::detail::HardClipAlgorithm< T >, dspark::detail::ExciterAlgorithm< T >, dspark::detail::WavefolderAlgorithm< T >, dspark::detail::BitcrusherAlgorithm< T >, dspark::detail::TapeAlgorithm< T >, dspark::detail::TransformerAlgorithm< T >, dspark::detail::DownsampleAlgorithm< T >, dspark::detail::CurveAlgorithm< T >, and dspark::detail::MultiStageAlgorithm< T >.
|
inlinenoexcept |
Latches the order for the coming block (audio thread, before update()) and the common second-order delay in processing samples (1 to kMaxDelay; Saturation passes 1 at 1x, 4 at 2x and 3 from 4x). Entering order 2 arms every channel: its first sample seeds the kernel history and the delay line with the current input, so the delay is inserted as held samples instead of a step from stale history. The off and first-order paths keep no second-order history at all.
Definition at line 122 of file Saturation.h.
|
inlinenoexcept |
The latched order (audio thread).
Definition at line 131 of file Saturation.h.
|
inlinenoexcept |
The common delay less the one sample of a second-order kernel.
Definition at line 140 of file Saturation.h.
|
pure virtualnoexcept |
Prepares the algorithm with the current audio specification.
Implemented in dspark::detail::TanhAlgorithm< T >, dspark::detail::TubeAlgorithm< T >, dspark::detail::HardClipAlgorithm< T >, dspark::detail::ExciterAlgorithm< T >, dspark::detail::WavefolderAlgorithm< T >, dspark::detail::BitcrusherAlgorithm< T >, dspark::detail::CurveAlgorithm< T >, dspark::detail::TapeAlgorithm< T >, dspark::detail::TransformerAlgorithm< T >, dspark::detail::DownsampleAlgorithm< T >, and dspark::detail::MultiStageAlgorithm< T >.
|
pure virtualnoexcept |
Resets internal states (filters, phase, memory).
Implemented in dspark::detail::TanhAlgorithm< T >, dspark::detail::TubeAlgorithm< T >, dspark::detail::HardClipAlgorithm< T >, dspark::detail::ExciterAlgorithm< T >, dspark::detail::WavefolderAlgorithm< T >, dspark::detail::BitcrusherAlgorithm< T >, dspark::detail::TapeAlgorithm< T >, dspark::detail::TransformerAlgorithm< T >, dspark::detail::DownsampleAlgorithm< T >, dspark::detail::CurveAlgorithm< T >, and dspark::detail::MultiStageAlgorithm< T >.
|
inlineprotectednoexcept |
Definition at line 203 of file Saturation.h.
|
inlinenoexcept |
Antiderivative antialiasing order on the memoryless curves: 0 off, 1 first order (SoftClip/Tube/HardClip), 2 second order (SoftClip/Tube/HardClip/Wavefolder/Transformer/Exciter/Tape and every MultiStage stage from 2x, Bilbao et al. 2017). Order 2 delays every algorithm by the same number of processing samples (latchOrder()): the kernels delay by one and are padded to it, the others are delayed by all of it, so a crossfade between any two stays aligned. Default 0.
Definition at line 110 of file Saturation.h.
|
inlineprotectednoexcept |
True once per channel after entering order 2 (or a reset).
Definition at line 153 of file Saturation.h.
|
inlinevirtualnoexcept |
Updates internal coefficients dependent on block-rate parameters.
Reimplemented in dspark::detail::MultiStageAlgorithm< T >, dspark::detail::BitcrusherAlgorithm< T >, dspark::detail::TapeAlgorithm< T >, dspark::detail::DownsampleAlgorithm< T >, dspark::detail::CurveAlgorithm< T >, and dspark::detail::TransformerAlgorithm< T >.
Definition at line 96 of file Saturation.h.
|
protected |
Definition at line 211 of file Saturation.h.
|
protected |
Definition at line 145 of file Saturation.h.
|
protected |
Channels whose order-2 history must be seeded.
Definition at line 148 of file Saturation.h.
|
protected |
Latched common second-order delay.
Definition at line 147 of file Saturation.h.
|
protected |
Channels whose delay line must be seeded.
Definition at line 149 of file Saturation.h.
|
protected |
Channels whose interpolator must be seeded.
Definition at line 150 of file Saturation.h.
|
protected |
Definition at line 212 of file Saturation.h.
|
staticconstexpr |
Definition at line 85 of file Saturation.h.
|
staticconstexpr |
Definition at line 142 of file Saturation.h.
|
protected |
Latched order (audio thread).
Definition at line 146 of file Saturation.h.