32#ifndef SBL_DSP_WIDGETS_SHAPER_HPP_
33#define SBL_DSP_WIDGETS_SHAPER_HPP_
72 if (su < 0.0f) su = 0.0f;
73 if (su > 1.0f) su = 1.0f;
91 if (su < 0.0f) su = 0.0f;
92 if (su > 1.0f) su = 1.0f;
108 if (su < 0.0f) su = 0.0f;
109 if (su > 1.0f) su = 1.0f;
111 target_drive_ = drive;
114 op_drive_.
reset(drive);
127 if (su < 0.0f) su = 0.0f;
128 if (su > 1.0f) su = 1.0f;
156 const float* depth_mod =
nullptr,
float mod_depth = 0.0f) {
158 float drive_target = target_drive_;
159 float mix_target = target_mix_;
165 for (uint16_t i = 0; i < frames; ++i) {
166 float d = depth_ramp.
next();
167 if (depth_mod !=
nullptr) {
168 d += depth_mod[i] * mod_depth;
169 if (d < 0.0f) d = 0.0f;
171 float bias = bias_ramp.
next();
172 float drive = op_drive_.
process(drive_target);
173 float mix = op_mix_.
process(mix_target);
176 float x = dry + bias;
180 x = saturator_.
process(x, drive);
182 float x_scaled = x * d;
185 float x_mid = (os_prev_ + x_scaled) * 0.5f;
193 x = 0.25f * decim_prev_ + 0.5f * y0 + 0.25f * y1;
197 x *= compensation_gain(d);
201 buf[i] = dry + (x - dry) * mix;
205 drive_ = op_drive_.
value();
206 mix_ = op_mix_.
value();
221 void set_depth(
float depth) {
222 depth_ = (depth < 0.0f) ? 0.0f : depth;
223 target_depth_ = depth_;
228 void set_bias(
float bias) {
235 void set_drive(
float drive) {
236 drive_ = (drive < 1.0f) ? 1.0f : drive;
237 target_drive_ = drive_;
238 op_drive_.
reset(drive_);
243 void set_mix(
float mix) {
244 if (mix < 0.0f) mix = 0.0f;
245 if (mix > 1.0f) mix = 1.0f;
252 void ensure_smoothers() {
253 if (!smoothers_configured_) {
256 op_drive_.
reset(target_drive_);
257 op_mix_.
reset(target_mix_);
259 smoothers_configured_ =
true;
263 comp::WavefoldAA fold_;
264 comp::WarmSaturator saturator_;
269 bool compensate_ =
true;
270 float os_prev_ = 0.0f;
271 float decim_prev_ = 0.0f;
274 primitives::ParameterSmoother op_drive_;
275 primitives::ParameterSmoother op_mix_;
276 float target_depth_ = 1.0f;
277 float target_bias_ = 0.03f;
278 float target_drive_ = 1.3f;
279 float target_mix_ = 1.0f;
280 bool depth_init_ =
false;
281 bool bias_init_ =
false;
282 bool drive_init_ =
false;
283 bool mix_init_ =
false;
284 bool smoothers_configured_ =
false;
288 static float compensation_gain(
float depth) {
289 return (depth > 1.0f) ? 1.0f / sqrtf(depth) : 1.0f;
void set_asymmetry(float k)
Set asymmetry depth (structural character parameter)
float process(float x, float drive)
Process a single sample with per-sample drive.
float process(float x)
Process a single sample (pre-multiplied by depth)
float next()
Get next interpolated value.
void reset()
Reset to zero.
void set_time_ms(float ms, float rate_hz)
Compute coefficient from settling time in milliseconds.
float process(float target)
Process one sample toward target.
float value() const
Current smoothed value.
Fixed-point constants and audio sample types.
RAII parameter interpolator.
One-pole parameter smoother.
Warm saturation composition.
ADAA Wavefolder (Audio Stack — Compositions)