Struct Linear Smoother
pub struct LinearSmoother { /* private fields */ }Expand description
A linear transition lasting exactly the configured number of samples.
After retargeting, the first Self::next_value advances by 1/N of the
distance and the Nth reaches the exact target. Zero samples means immediate.
A changed target starts from the current effective value. An identical
target does not restart an existing ramp. Sample progress makes output
independent of block boundaries. Interpolation uses f64 to keep finite f32
endpoints from overflowing intermediate arithmetic. This type allocates
nothing and performs bounded work per call.
Implementations§
§impl LinearSmoother
impl LinearSmoother
pub fn new(initial: f32, ramp_samples: u32) -> Result<Self, SmoothingError>
pub fn current(&self) -> f32
pub fn target(&self) -> f32
pub fn is_smoothing(&self) -> bool
pub fn set_target(&mut self, target: f32) -> Result<(), SmoothingError>
pub fn next_value(&mut self) -> f32
pub fn reset(&mut self)
pub fn reset(&mut self)
Snap to the latest target without changing the configured duration.
Trait Implementations§
§impl Clone for LinearSmoother
impl Clone for LinearSmoother
§fn clone(&self) -> LinearSmoother
fn clone(&self) -> LinearSmoother
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · §fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for LinearSmoother
Auto Trait Implementations§
impl Freeze for LinearSmoother
impl RefUnwindSafe for LinearSmoother
impl Send for LinearSmoother
impl Sync for LinearSmoother
impl Unpin for LinearSmoother
impl UnsafeUnpin for LinearSmoother
impl UnwindSafe for LinearSmoother
Blanket Implementations§
§impl<T> BorrowMut<T> for T
impl<T> BorrowMut<T> for T
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more