AUDIO
Source snapshot · 11 November 2026

API reference / ravet_foundation::Processor

Trait Processor 

pub trait Processor<S: Sample = f32> {
    // Required methods
    fn prepare(&mut self, config: ProcessConfig) -> Result<(), PrepareError>;
    fn process(
        &mut self,
        block: &mut ProcessBlock<'_, '_, '_, S>,
    ) -> ProcessStatus;
    fn reset(&mut self);
    fn deactivate(&mut self);

    // Provided methods
    fn start_audio(&mut self) -> Result<(), ProcessError> { ... }
    fn stop_audio(&mut self) { ... }
    fn try_reset(&mut self) -> Result<(), ProcessError> { ... }
    fn latency_samples(&self) -> u32 { ... }
    fn tail(&self) -> Tail { ... }
}
Expand description

A portable processor, exclusively owned by the processing thread.

Create -> prepare -> process/reset -> deactivate. Call prepare/deactivate only after callbacks stop. Explicit session consumers optionally bracket rendering/reset with start_audio -> stop_audio on the audio owner, ending before transfer/deactivation. A failed prepare must leave the processor inactive. Reset preserves configuration and requested parameter values, clears history, and runs exclusively without allocation. Deactivate stops prepared processing but may retain parameter values for reactivation.

Processing must validate layout, size, and the complete event stream before mutating state. Validation faults reject before state changes, silence all active outputs and discard emitted events using ProcessBlock::clear_outputs. BackendFailure also silences/discards outputs but cannot roll back native histories; consumers stop/reset/rebuild under their session policy. Valid processing initializes every output frame, consumes events even in zero-frame blocks, and performs no allocation, deallocation, blocking, or I/O. Unknown supported event kinds/parameter IDs may be ignored, as stated by the processor. These are implementor obligations, not type guarantees. No Sync bound is imposed. ABI panic containment belongs to format adapters.

Required Methods§

fn prepare(&mut self, config: ProcessConfig) -> Result<(), PrepareError>

fn process(&mut self, block: &mut ProcessBlock<'_, '_, '_, S>) -> ProcessStatus

fn reset(&mut self)

fn deactivate(&mut self)

Provided Methods§

fn start_audio(&mut self) -> Result<(), ProcessError>

Optional explicit audio-owner session start, after prepare and before rendering. Default is a no-op. Consumers using these hooks call once on the audio owner and stop there before transfer/deactivation. Failure must leave this processor stopped; earlier successful nodes may be stopped. Hooks follow prepared callback allocation/locking/I/O obligations. Existing adapters do not implicitly opt in; explicit graph sessions supply them.

fn stop_audio(&mut self)

End an explicitly started session on its audio owner, without deactivation or storage destruction. Default no-op; preparation/history may be retained.

fn try_reset(&mut self) -> Result<(), ProcessError>

Attempt history reset without allocating or changing configuration. Existing processors delegate to their successful legacy reset by default. A refusal may follow earlier reset work; consumers must remain faulted.

fn latency_samples(&self) -> u32

Prepared algorithmic latency in samples. Changes are advertised by adapters using their format’s restart/latency protocol outside the audio callback.

fn tail(&self) -> Tail

Decay policy after input stops. Adapters must map this to the host protocol.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§