pub enum SmoothingStyle {
    OversamplingAware(Arc<AtomicF32>, &'static SmoothingStyle),
    None,
    Linear(f32),
    Logarithmic(f32),
    Exponential(f32),
}
Expand description

Controls if and how parameters gets smoothed.

Variants§

§

OversamplingAware(Arc<AtomicF32>, &'static SmoothingStyle)

Wraps another smoothing style to create a multi-rate oversampling-aware smoother for a parameter that’s used in an oversampled part of the plugin. The Arc<AtomicF32> indicates the oversampling amount, where 1.0 means no oversampling. This value can change at runtime, and it effectively scales the sample rate when computing new smoothing coefficients when the parameter’s value changes.

§

None

No smoothing is applied. The parameter’s value field contains the latest sample value available for the parameters.

§

Linear(f32)

Smooth parameter changes so the current value approaches the target value at a constant rate. The target value will be reached in exactly this many milliseconds.

§

Logarithmic(f32)

Smooth parameter changes such that the rate matches the curve of a logarithmic function, starting out slow and then constantly increasing the slope until the value is reached. The target value will be reached in exactly this many milliseconds. This is useful for smoothing things like frequencies and decibel gain value. The caveat is that the value may never reach 0, or you will end up multiplying and dividing things by zero. Make sure your value ranges don’t include 0.

§

Exponential(f32)

Smooth parameter changes such that the rate matches the curve of an exponential function, starting out fast and then tapering off until the end. This is a single-pole IIR filter under the hood, while the other smoothing options are FIR filters. This means that the exact value would never be reached. Instead, this reaches 99.99% of the value target value in the specified number of milliseconds, and it then snaps to the target value in the last step. This results in a smoother transition, with the caveat being that there will be a tiny jump at the end. Unlike the Logarithmic option, this does support crossing the zero value.

Implementations§

source§

impl SmoothingStyle

source

pub fn num_steps(&self, sample_rate: f32) -> u32

Compute the number of steps to reach the target value based on the sample rate and this smoothing style’s duration.

source

pub fn step_size(&self, start: f32, target: f32, num_steps: u32) -> f32

Compute the step size for this smoother. num_steps can be obtained using SmoothingStyle::num_steps(). Check the source code of the SmoothingStyle::next() and SmoothingStyle::next_step() functions for details on how these values should be used.

source

pub fn next(&self, current: f32, target: f32, step_size: f32) -> f32

Compute the next value from current leading up to target using the step_size computed using SmoothingStyle::step_size(). Depending on the smoothing style this function may never completely reach target, so you will need to snap to target yourself after computing the target number of steps.

See the docstring on the SmoothingStyle::next_step() function for the formulas used.

source

pub fn next_step( &self, current: f32, target: f32, step_size: f32, steps: u32 ) -> f32

The same as next(), but with the option to take more than one step at a time. Calling next_step() with step count n gives the same result as applying next() n times to a value, but is more efficient to compute. next_step() with 1 step is equivalent to step().

See the docstring on the SmoothingStyle::next_step() function for the formulas used.

Trait Implementations§

source§

impl Clone for SmoothingStyle

source§

fn clone(&self) -> SmoothingStyle

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SmoothingStyle

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> ToSample<U> for Twhere U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Any for Twhere T: Any,

§

impl<T> CloneAny for Twhere T: Any + Clone,

§

impl<S, T> Duplex<S> for Twhere T: FromSample<S> + ToSample<S>,