pub struct FloatParam {
pub info: ParamInfo,
pub smoother: Smoother,
/* private fields */
}Expand description
A continuous floating-point parameter.
Fields§
§info: ParamInfo§smoother: SmootherImplementations§
Source§impl FloatParam
impl FloatParam
pub fn new(info: ParamInfo, smoothing: SmoothingStyle) -> Self
Sourcepub fn value_usize(&self) -> usize
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.
Sourcepub fn value_i32(&self) -> i32
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.
Sourcepub fn value_u8(&self) -> u8
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.
Sourcepub fn is_smoothing(&self) -> bool
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.
}Trait Implementations§
Source§impl FloatParamReadF32 for FloatParam
impl FloatParamReadF32 for FloatParam
Source§fn read_block<const N: usize>(&self) -> [f32; N]
fn read_block<const N: usize>(&self) -> [f32; N]
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
fn read_after(&self, n_samples: usize) -> f32
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 value(&self) -> f32
fn value(&self) -> f32
set_normalized / host automation),
not the smoothed output. Use Self::read / Self::current
in the DSP loop.Source§impl FloatParamReadF64 for FloatParam
impl FloatParamReadF64 for FloatParam
fn read(&self) -> f64
Source§fn read_block<const N: usize>(&self) -> [f64; N]
fn read_block<const N: usize>(&self) -> [f64; N]
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
fn read_after(&self, n_samples: usize) -> f64
FloatParamReadF32::read_after; one widen
on top of the same one-atomic-pair fast path.