Skip to main content

Process

Trait Process 

Source
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§

Source

type Error: From<RenderError>

Processor error that can also represent the render scheduler’s input and timing errors.

Required Methods§

Source

fn sample_rate(&self) -> f64

Prepared sample rate in samples per second.

Source

fn max_block_size(&self) -> usize

Prepared maximum frames per processing call.

Source

fn input_channels(&self) -> usize

Number of input channels required in planar buffer order.

Source

fn output_channels(&self) -> usize

Number of output channels produced in planar buffer order.

Source

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.

Source

fn tail(&self) -> Result<Tail, Self::Error>

Current native tail duration at render start.

Source

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§

Source

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.

Source

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.

Source

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".

Implementors§