Struct SlewRateLimiter
pub struct SlewRateLimiter { /* private fields */ }Expand description
Models op-amp slew rate limiting for physically accurate WDF processing.
Real op-amps have a finite maximum rate of output voltage change (dV/dt), measured in V/µs. When the signal demands a faster slew than the op-amp can deliver, the output “rounds off” — this is the mechanism behind the distinctive compression character of slow op-amps like the LM308 (RAT) versus fast ones like the TL072 (Klon).
The slew rate limiter operates as a per-sample voltage clamp on the
derivative: |V[n] - V[n-1]| ≤ slew_rate * dt, where dt = 1/fs.
This is NOT a WDF root — it sits in the signal path between stages,
modeling the op-amp’s output stage limitation.
Thin wrapper over the shared [crate::stage::NonIdealFxState] dV/dt clamp.
Carries NO copy of the slew math: process delegates to
NonIdealFxState::slew_step (the single source of truth) and only adds the
finite guard. Only test code uses this type now — the live SPQR pipeline
applies slew in-loop via NonIdealFxState directly.
Implementations§
§impl SlewRateLimiter
impl SlewRateLimiter
pub fn new(slew_rate_v_per_us: f64, sample_rate: f64) -> SlewRateLimiter
pub fn new(slew_rate_v_per_us: f64, sample_rate: f64) -> SlewRateLimiter
Create a slew rate limiter from a slew rate in V/µs and sample rate.
Slew rate values from real op-amps:
- LM308: 0.3 V/µs (the RAT’s character)
- LM741: 0.5 V/µs (vintage slow)
- JRC4558: 1.7 V/µs (Tube Screamer warmth)
- NE5532: 9.0 V/µs (studio clean)
- TL072: 13.0 V/µs (modern, transparent)
- CA3080: 50.0 V/µs (OTA, essentially transparent)
pub fn process(&mut self, input: f64) -> f64
pub fn process(&mut self, input: f64) -> f64
Process one sample through the slew rate limiter.
If the requested voltage change exceeds what the op-amp can deliver in one sample period, the output is clamped to the maximum slew rate. This creates asymmetric HF compression — the exact behavior that makes the LM308 RAT sound different from a TL072 RAT.
pub fn set_sample_rate(&mut self, sample_rate: f64)
pub fn set_sample_rate(&mut self, sample_rate: f64)
Update sample rate and recompute max_dv.
pub fn reset(&mut self)
pub fn reset(&mut self)
Reset internal state.
pub fn is_limiting(&self) -> bool
pub fn is_limiting(&self) -> bool
Check if slew limiting is currently active (for diagnostics).
Returns the ratio of actual dV to max_dv for the last sample. Values > 1.0 mean the limiter was engaged.
Trait Implementations§
§impl Clone for SlewRateLimiter
impl Clone for SlewRateLimiter
§fn clone(&self) -> SlewRateLimiter
fn clone(&self) -> SlewRateLimiter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more