pub trait Process<S: Sample> {
type Error: From<RenderError>;
// Required methods
fn sample_rate(&self) -> f64;
fn max_block_size(&self) -> usize;
fn input_channels(&self) -> usize;
fn output_channels(&self) -> usize;
fn latency(&self) -> Result<u32, Self::Error>;
fn tail(&self) -> Result<Tail, Self::Error>;
fn process(
&mut self,
context: &BlockContext,
input: &[&[S]],
output: &mut [&mut [S]],
automation: &[AutomationEvent],
events: &Events,
produced: &mut Events,
) -> Result<(), Self::Error>;
// Provided methods
fn begin_render(&mut self) -> Result<(), Self::Error> { ... }
fn validate_automation(
&mut self,
automation: &[AutomationEvent],
) -> Result<(), Self::Error> { ... }
fn validate_events(&mut self, _events: &Events) -> Result<(), Self::Error> { ... }
}Expand description
A prepared processor the render rules can drive.
Required Associated Types§
Sourcetype Error: From<RenderError>
type Error: From<RenderError>
Processor error that can also represent the render scheduler’s input and timing errors.
Required Methods§
Sourcefn sample_rate(&self) -> f64
fn sample_rate(&self) -> f64
Prepared sample rate in samples per second.
Sourcefn max_block_size(&self) -> usize
fn max_block_size(&self) -> usize
Prepared maximum frames per processing call.
Sourcefn input_channels(&self) -> usize
fn input_channels(&self) -> usize
Number of input channels required in planar buffer order.
Sourcefn output_channels(&self) -> usize
fn output_channels(&self) -> usize
Number of output channels produced in planar buffer order.
Sourcefn latency(&self) -> Result<u32, Self::Error>
fn latency(&self) -> Result<u32, Self::Error>
The latency the processor’s output has. It must not change while a render runs, so that one alignment holds; plughost’s processors keep the latency they were prepared or last reset with.
Sourcefn process(
&mut self,
context: &BlockContext,
input: &[&[S]],
output: &mut [&mut [S]],
automation: &[AutomationEvent],
events: &Events,
produced: &mut Events,
) -> Result<(), Self::Error>
fn process( &mut self, context: &BlockContext, input: &[&[S]], output: &mut [&mut [S]], automation: &[AutomationEvent], events: &Events, produced: &mut Events, ) -> Result<(), Self::Error>
Processes one block. Every input and output slice has the same length, at most
max_block_size; automation and MIDI are in offset order, inside the block. Points hold
their values from their offsets, including equal-offset input order. Native adapters own
any subdivision needed to avoid implicit interpolation between point edits. produced
holds one block’s events (Events::for_block) and is replaced with the block’s output
events in offset order, with block offsets.
Provided Methods§
Sourcefn begin_render(&mut self) -> Result<(), Self::Error>
fn begin_render(&mut self) -> Result<(), Self::Error>
Called once as a render starts, before validating input or reading the latency and tail.
Refuse here if the processor is not prepared. A processor whose
latency changed without the change being applied yet refuses here with
RenderError::LatencyNotApplied, since the whole render would keep the old alignment.
Sourcefn validate_automation(
&mut self,
automation: &[AutomationEvent],
) -> Result<(), Self::Error>
fn validate_automation( &mut self, automation: &[AutomationEvent], ) -> Result<(), Self::Error>
Validate all scheduled targets before the render advances DSP state. Implementors with automation must check slot/parameter identity, write access and automatable metadata.
Sourcefn validate_events(&mut self, _events: &Events) -> Result<(), Self::Error>
fn validate_events(&mut self, _events: &Events) -> Result<(), Self::Error>
Validate the event destinations for the entire render before DSP state advances. Processors with configured input ports must override this to reject unavailable ports. Offsets, ordering and event values are already checked by the renderer. The default imposes no port restrictions, preserving processors that do not expose port metadata.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".