Skip to main content

FloatParam

Struct FloatParam 

Source
pub struct FloatParam {
    pub info: ParamInfo,
    pub smoother: Smoother,
    /* private fields */
}
Expand description

A continuous floating-point parameter.

Fields§

§info: ParamInfo§smoother: Smoother

Implementations§

Source§

impl FloatParam

Source

pub fn new(info: ParamInfo, smoothing: SmoothingStyle) -> Self

Source

pub fn set_value(&self, v: f64)

Set the plain value (used by host automation).

Source

pub fn value_usize(&self) -> usize

Read the value rounded to the nearest non-negative usize. Use this for discrete-range params consumed as array indices. Negatives, NaN, and infinities saturate at 0 / usize::MAX.

Source

pub fn value_i32(&self) -> i32

Read the value rounded to the nearest i32. Out-of-range values saturate at i32::MIN / i32::MAX; NaN → 0.

Source

pub fn value_u8(&self) -> u8

Read the value rounded to the nearest u8. Negatives clamp to 0; values above 255 saturate at u8::MAX; NaN → 0.

Source

pub fn is_smoothing(&self) -> bool

True when the smoother is mid-step toward a new target. Inverse of Smoother::is_converged.

Use to branch in process() between a constant-gain fast path (smoothers at target, gain identical across the whole block, one gain_block per channel) and the envelope slow path (read_block + per-sample envelope + chunks_mut). SmoothingStyle::None always reports false here, so the fast path is unconditional for plugins that disable smoothing.

if !self.params.gain.is_smoothing() && !self.params.pan.is_smoothing() {
    // fast path: gain is constant for the whole block.
} else {
    // slow path: envelope precompute + chunked apply.
}
Source

pub fn id(&self) -> u32

Parameter ID.

Trait Implementations§

Source§

impl FloatParamReadF32 for FloatParam

Source§

fn read(&self) -> f32

Next smoothed value. Call once per sample in process().
Source§

fn read_block<const N: usize>(&self) -> [f32; N]

Advance the smoother by N samples in one call, returning the per-sample values as a stack array. One atomic load and one atomic store regardless of N, vs. one of each per sample for Self::read; pulls smoother traffic out of the hot inner loop. Pair with AudioBuffer::chunks_mut (in truce-core) to drive an N-sample chunked DSP loop.
Source§

fn read_after(&self, n_samples: usize) -> f32

Advance the smoother by n_samples in one call, returning only the final value. Use for block-rate DSP - hard gates, mode switches, anything that needs one smoothed value per audio block. Pass buffer.num_samples() to keep the smoother’s wall-clock convergence time matching the smoother declaration (smooth = "exp(20)" then actually settles in ~20 ms instead of ~20 blocks). One atomic load + one atomic store; the intermediate envelope from Self::read_block is skipped.
Source§

fn current(&self) -> f32

Current smoothed value without advancing.
Source§

fn value(&self) -> f32

Raw target value (post-set_normalized / host automation), not the smoothed output. Use Self::read / Self::current in the DSP loop.
Source§

impl FloatParamReadF64 for FloatParam

Source§

fn read(&self) -> f64

Source§

fn read_block<const N: usize>(&self) -> [f64; N]

f64 view of FloatParamReadF32::read_block; the smoother itself stores f32 internally, so this is a per-element widen on top of the same one-atomic-pair fast path.
Source§

fn read_after(&self, n_samples: usize) -> f64

f64 view of FloatParamReadF32::read_after; one widen on top of the same one-atomic-pair fast path.
Source§

fn current(&self) -> f64

Source§

fn value(&self) -> f64

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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.

Source§

impl<T, U> Into<U> for T
where 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.

Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.