pub trait FloatParamReadF32 {
// Required methods
fn read(&self) -> f32;
fn read_block<const N: usize>(&self) -> [f32; N];
fn read_after(&self, n_samples: usize) -> f32;
fn current(&self) -> f32;
fn value(&self) -> f32;
}Expand description
Precision-routed read accessors for FloatParam at f32.
The plugin prelude (truce::prelude / truce::prelude32) imports
this trait via pub use … as _;, so plugin code reads:
use truce::prelude::*;
let gain = self.params.gain.read(); // f32 - no annotation neededThe trait’s methods shadow nothing - FloatParam has no inherent
read / value / current, so name resolution picks the one
(and only one) trait that’s in scope. Importing prelude64
instead brings FloatParamReadF64 into scope and the same
source resolves to f64. Importing both preludes is a
compile error (multiple applicable items in scope) - which is
the right error for a file that hasn’t committed to a precision.
Required Methods§
Sourcefn read_block<const N: usize>(&self) -> [f32; N]
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.
Sourcefn read_after(&self, n_samples: usize) -> f32
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.
Sourcefn value(&self) -> f32
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".