pub trait Processor: Send {
// Required methods
fn prepare(&mut self, sample_rate: u32, max_block: usize);
fn process(
&mut self,
ctx: &ProcessCtx,
inputs: &[&[f32]],
outputs: &mut [&mut [f32]],
);
fn reset(&mut self);
fn save_state(&self) -> StateBlob;
fn load_state(&mut self, state: &StateBlob) -> Result<(), StateError>;
// Provided methods
fn inputs_per_output(&self) -> usize { ... }
fn latency_samples(&self) -> u32 { ... }
fn history_samples(&self) -> u32 { ... }
}Expand description
Stateful DSP unit whose process method performs no allocation or locking.
Required Methods§
Sourcefn prepare(&mut self, sample_rate: u32, max_block: usize)
fn prepare(&mut self, sample_rate: u32, max_block: usize)
Configures non-real-time state before processing begins.
Sourcefn process(
&mut self,
ctx: &ProcessCtx,
inputs: &[&[f32]],
outputs: &mut [&mut [f32]],
)
fn process( &mut self, ctx: &ProcessCtx, inputs: &[&[f32]], outputs: &mut [&mut [f32]], )
Processes planar channel slices supplied by the host.
A prepared processor that reads one input per output
(Self::inputs_per_output) writes every sample of each output it
has an input for, up to the shortest of them: a
crate::ProcessorChain hands that output on as the next node’s
input.
Sourcefn save_state(&self) -> StateBlob
fn save_state(&self) -> StateBlob
Serializes history at an offline chunk boundary.
Sourcefn load_state(&mut self, state: &StateBlob) -> Result<(), StateError>
fn load_state(&mut self, state: &StateBlob) -> Result<(), StateError>
Restores history saved by a processor of the same type, prepared alike, whole or not at all.
A state the processor saved itself always loads back: a
crate::ProcessorChain relies on that to undo the nodes it has
loaded when a later one refuses its part.
§Errors
Returns StateError, and leaves the processor as it was, for a
state that does not fit it or holds a value it never keeps.
Provided Methods§
Sourcefn inputs_per_output(&self) -> usize
fn inputs_per_output(&self) -> usize
How many input channels the processor reads for each output channel:
1 for an effect, 2 for one that also reads a second bus after the
first (a sidechain, or the other side of a crossfade). A
crate::ProcessorChain gives each node only its own channels, so
it takes only processors that read one.
Sourcefn latency_samples(&self) -> u32
fn latency_samples(&self) -> u32
Algorithmic delay that the graph host must compensate.
Sourcefn history_samples(&self) -> u32
fn history_samples(&self) -> u32
Additional source history for a cold seek, excluding algorithmic delay. Built-in recursive processors use a finite settling horizon; this is an approximation to uninterrupted playback, not a bit-exact state snapshot.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".