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


Public Member Functions | |
| void | prepare (const AudioSpec &spec) noexcept override |
| Prepares the algorithm with the current audio specification. | |
| void | reset () noexcept override |
| Resets internal states (filters, phase, memory). | |
| Saturation< T >::Algorithm | getType () const noexcept override |
| Identifies the exact algorithm type for CRTP static dispatch. | |
| void | update (T drive, T, const AudioSpec &spec) noexcept override |
| Updates internal coefficients dependent on block-rate parameters. | |
| T | processSample (T sample, T drive, T character, int ch) noexcept |
| T | processSecond (T sample, T drive, T character, int ch) noexcept |
Public Member Functions inherited from dspark::detail::SaturationAlgorithm< T > | |
| virtual | ~SaturationAlgorithm ()=default |
| 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 |
Additional Inherited Members | |
Static Public Attributes inherited from dspark::detail::SaturationAlgorithm< T > | |
| static constexpr int | kAaCh = 16 |
| static constexpr int | kMaxDelay = 4 |
Protected Member Functions inherited from dspark::detail::SaturationAlgorithm< T > | |
| 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 inherited from dspark::detail::SaturationAlgorithm< T > | |
| 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 1044 of file Saturation.h.
|
inlineoverridevirtualnoexcept |
Identifies the exact algorithm type for CRTP static dispatch.
Implements dspark::detail::SaturationAlgorithm< T >.
Definition at line 1103 of file Saturation.h.
|
inlineoverridevirtualnoexcept |
Prepares the algorithm with the current audio specification.
Implements dspark::detail::SaturationAlgorithm< T >.
Definition at line 1085 of file Saturation.h.
|
inlinenoexcept |
Tape under correct AC bias magnetises along the ANHYSTERETIC curve (the bias linearises the loop away) - so the static nonlinearity is M = Ms * L((H + alpha*M)/a), solved per sample by Newton-Raphson from the previous sample's M (warm start: 3 iterations are plenty, and f' = 1 - 3*alpha*L' >= 1 - alpha > 0 has no singularity).
Scaling: Ms = 3a and out = (1-alpha)*M give exactly unit small-signal gain over H = in*drive and a +-1 ceiling, matching the contract of every other algorithm in the pool. The previous formulation stepped M by dM ~ ManDiff*|dH|/(a+|dH|) - a coercivity of ~1.0 in absolute full-scale units, i.e. tape with NO bias: signals below ~0 dBFS*drive fell into a dead zone (measured: -60 dBFS in -> -121 dBFS out, output ~ input^2), wiping out quiet passages and low-level harmonic detail.
Definition at line 1141 of file Saturation.h.
|
inlinenoexcept |
Second-order sample: the AdaaTape kernel on the magnetisation curve between the same head-bump and roll-off filters (one sample of delay). The plain path's warm start follows, so switching back is seamless.
Definition at line 1169 of file Saturation.h.
|
inlineoverridevirtualnoexcept |
Resets internal states (filters, phase, memory).
Implements dspark::detail::SaturationAlgorithm< T >.
Definition at line 1096 of file Saturation.h.
|
inlineoverridevirtualnoexcept |
Updates internal coefficients dependent on block-rate parameters.
Reimplemented from dspark::detail::SaturationAlgorithm< T >.
Definition at line 1105 of file Saturation.h.