Sound Byte Libs 0.5.1-121-g3358a44
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
warm_saturator.hpp
Go to the documentation of this file.
1// sbl/dsp/comp/warm_saturator.hpp — Warm saturation composition
2//
3// Asymmetric saturation that adds even-order harmonics for tube/transformer
4// coloration. Composes gain + AsymmetricShaper + SoftLimiter.
5//
6// Signal flow: input * drive → asymmetric shaping → soft limiting → output
7//
8// Drive and asymmetry are both configurable. The old warm_saturate() free
9// function hardcoded asymmetry at 0.1 — this composition makes it explicit.
10//
11// Usage:
12// sbl::dsp::comp::WarmSaturator sat;
13// sat.set_asymmetry(0.1f); // character: how much even-harmonic warmth
14// float out = sat.process(x, drive); // drive applied per-sample
15
16#ifndef SBL_DSP_COMP_WARM_SATURATOR_HPP_
17#define SBL_DSP_COMP_WARM_SATURATOR_HPP_
18
19#include <cstdint>
20
23
24namespace sbl::dsp::comp {
25
27public:
28 /// Set asymmetry depth (structural character parameter)
29 void set_asymmetry(float k) { shaper_.set_asymmetry(k); }
30
31 /// Current asymmetry depth
32 float asymmetry() const { return shaper_.asymmetry(); }
33
34 /// Process a single sample with per-sample drive
35 float process(float x, float drive) {
36 float d = x * drive;
37 return limiter_.process(shaper_.process(d));
38 }
39
40 /// Process a block in-place with constant drive
41 void process(float* buf, uint16_t frames, float drive) {
42 for (uint16_t i = 0; i < frames; ++i) {
43 buf[i] = process(buf[i], drive);
44 }
45 }
46
47private:
50};
51
52} // namespace sbl::dsp::comp
53
54#endif // SBL_DSP_COMP_WARM_SATURATOR_HPP_
Asymmetric distortion primitive.
float asymmetry() const
Current asymmetry depth.
void set_asymmetry(float k)
Set asymmetry depth (structural character parameter)
void process(float *buf, uint16_t frames, float drive)
Process a block in-place with constant drive.
float process(float x, float drive)
Process a single sample with per-sample drive.
float process(float x)
Process a single sample.
void set_asymmetry(float k)
Set asymmetry depth (not a signal — structural character parameter)
float asymmetry() const
Current asymmetry depth.
float process(float x)
Process a single sample.
Compositions: subcircuits of primitives.
Soft limiter primitive.