19#ifndef SBL_DSP_COMP_ANALOG_DRIFT_HPP_
20#define SBL_DSP_COMP_ANALOG_DRIFT_HPP_
39 step_scale_ = 2.0f / control_rate_hz;
43 decay_ = 1.0f - 1.0f / (2.0f * control_rate_hz);
47 smooth_ = 1.0f / (0.5f * control_rate_hz);
55 walk_ += rng_.
bipolar() * step_scale_;
61 filtered_ += smooth_ * (walk_ - filtered_);
63 return filtered_ * amount;
67 float value()
const {
return filtered_; }
81 float filtered_ = 0.0f;
84 float step_scale_ = 0.01f;
85 float decay_ = 0.9975f;
86 float smooth_ = 0.01f;
AnalogDrift(uint32_t seed=1)
Construct with PRNG seed. Use a different seed for each instance.
void set_rate(float control_rate_hz)
void reset()
Reset drift state to zero.
float value() const
Current drift value (before amount scaling), for diagnostics.
float process(float amount)
void seed(uint32_t s)
Re-seed the PRNG (for test reproducibility).
float bipolar()
Random float in [-1.0, 1.0].
void seed(uint32_t s)
Set state directly (for test reproducibility).
Compositions: subcircuits of primitives.
Lightweight pseudorandom number generator.