|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Audio transformer: core hysteresis on the flux, LF bloom, HF bell. More...
#include "../Core/AudioBuffer.h"#include "../Core/AudioSpec.h"#include "../Core/Biquad.h"#include "../Core/DenormalGuard.h"#include "../Core/DspMath.h"#include "../Core/Hysteresis.h"#include "../Core/StateBlob.h"#include <algorithm>#include <atomic>#include <cmath>#include <cstddef>#include <cstdint>#include <numbers>#include <vector>

Go to the source code of this file.
Classes | |
| class | dspark::TransformerModel< T > |
| Physical audio-transformer coloration (flux-domain JA hysteresis). More... | |
Namespaces | |
| namespace | dspark |
| Main namespace for the DSPark framework. | |
Audio transformer: core hysteresis on the flux, LF bloom, HF bell.
What makes a transformer sound like a transformer is where its nonlinearity lives: the core saturates on magnetic FLUX, which is the time-integral of the winding voltage. At equal level, low frequencies integrate to much larger flux than highs (Phi ~ V/f), so distortion and compression concentrate in the low end - the classic "iron" low-frequency bloom - while the top stays clean.
The model implements that physics directly:
in -> leaky trapezoidal integrator (flux) -> Jiles-Atherton hysteresis -> exact algebraic inverse differentiator -> magnetizing-corner high-pass (finite Lm) -> leakage/capacitance HF bell -> out
The integrator/differentiator pair is an exact algebraic inverse, so the linear part of the JA loop passes transparently (verified by null test); everything you hear is the core's hysteresis acting on flux, with the loop's odd-dominant saturation, remanence memory and rate-dependent loss. The JA core is shared with TapeMachine (Core/Hysteresis.h), parameterised for an unbiased iron core (wider loop than biased tape).
Zero latency. The Saturation effect's lightweight Transformer algorithm remains as the cheap alternative; this is the physical one. Unlike the biased tape core, the leaky flux integrator continuously re-centres the loop, so the response is history-independent by construction (verified: 0.000 dB branch delta at programme level).
Threading model: parameter setters/getters are std::atomic based and safe from any thread (non-finite values are ignored; changes are published with a release store and consumed at the next block). prepare() is setup-thread only (allocates; invalid specs are ignored and an unprepared instance passes audio through). reset() belongs to the stream owner. getState()/setState() are setup/UI threads. The dry/wet mix is smoothed linearly over one block. Channels beyond the prepared count pass through untouched.
Dependencies: Core/Hysteresis.h, Core/Biquad.h, Core/AudioSpec.h, Core/AudioBuffer.h, Core/DspMath.h, Core/DenormalGuard.h, Core/StateBlob.h.
Definition in file TransformerModel.h.