pub struct SmoothedValue<S, T>where
S: Sample,
T: SmoothingStrategy,{ /* private fields */ }Expand description
A value that smoothly transitions to a target over time.
Uses the specified SmoothingStrategy to interpolate between values,
avoiding clicks and pops when parameters change.
Generic over S: Sample for the value type and T: SmoothingStrategy
for the interpolation method.
Implementations§
Source§impl<S, T> SmoothedValue<S, T>where
S: Sample,
T: SmoothingStrategy,
impl<S, T> SmoothedValue<S, T>where
S: Sample,
T: SmoothingStrategy,
Sourcepub fn new(initial_value: S) -> SmoothedValue<S, T>
pub fn new(initial_value: S) -> SmoothedValue<S, T>
Create a new SmoothedValue with the given initial value.
Uses default sample rate (44100.0) and ramp length (50ms).
Sourcepub fn reset(&mut self, sample_rate: f64, ramp_length_millis: f64)
pub fn reset(&mut self, sample_rate: f64, ramp_length_millis: f64)
Reset the sample rate and ramp length.
This recalculates the increment based on the new timing parameters. A minimum ramp length of 0.01ms is enforced to prevent clicks.
Sourcepub fn set_target_value(&mut self, value: S)
pub fn set_target_value(&mut self, value: S)
Set a new target value to smooth towards.
Sourcepub fn get_next_value(&mut self) -> S
pub fn get_next_value(&mut self) -> S
Get the next smoothed value (call once per sample).
Sourcepub fn is_smoothing(&self) -> bool
pub fn is_smoothing(&self) -> bool
Check if the value is still smoothing towards the target.
Sourcepub fn set_immediate(&mut self, value: S)
pub fn set_immediate(&mut self, value: S)
Immediately set both current and target to a value (no smoothing).
Trait Implementations§
Source§impl<S, T> Clone for SmoothedValue<S, T>
impl<S, T> Clone for SmoothedValue<S, T>
Source§fn clone(&self) -> SmoothedValue<S, T>
fn clone(&self) -> SmoothedValue<S, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more