Skip to main content

AudioGraph

Struct AudioGraph 

Source
pub struct AudioGraph { /* private fields */ }
Expand description

Clip chain -> track bus -> master bus graph with deterministic latency aggregation.

Buses whose chains differ in latency mix aligned: each bus is delayed to the longest clip-and-track latency before the mix, so the graph’s output is its input delayed by exactly Self::latency_samples, whichever chain a lookahead sits in. Each chain gets the context of the audio it receives.

Implementations§

Source§

impl AudioGraph

Source

pub fn new(layout: ChannelLayout, buses: usize) -> Self

Creates one clip chain and one track bus per input bus.

Source

pub const fn layout(&self) -> ChannelLayout

Channel layout every bus and the master run in.

Source

pub fn buses(&self) -> usize

Number of input buses, each with its own clip chain and track bus.

Source

pub fn clip_chain_mut(&mut self, bus: usize) -> Option<&mut ProcessorChain>

Mutable clip effect chain of bus; None past the last bus.

Source

pub fn track_bus_mut(&mut self, bus: usize) -> Option<&mut ProcessorChain>

Mutable track effect chain of bus; None past the last bus.

Source

pub fn master_mut(&mut self) -> &mut ProcessorChain

Mutable master effect chain.

Source

pub fn prepare(&mut self, sample_rate: u32, max_block: usize)

Prepares every allocation before realtime processing.

Source

pub fn latency_samples(&self) -> u32

Maximum serial latency among tracks plus master latency: how late the graph’s output is, every bus aligned to it.

Source

pub fn process( &mut self, ctx: &ProcessCtx, inputs: &[&[f32]], outputs: &mut [&mut [f32]], )

Processes flattened planar bus inputs (bus0-L, bus0-R, bus1-L, ...) into the first n samples of each output channel, for n the shortest output channel; a shorter bus is padded with silence, and a block longer than the prepared max_block runs in pieces. Without an input channel for every channel of every bus, an output channel for every channel of the layout, or a Self::prepare first, there is nothing to mix, and the outputs given are silenced.

Source

pub fn reset(&mut self)

Clears every graph node.

Source

pub fn save_state(&self) -> AudioGraphState

Captures every clip, track, and master processor history, and the audio the buses’ alignment holds.

Source

pub fn load_state( &mut self, state: &AudioGraphState, ) -> Result<(), GraphStateError>

Restores a state saved by a graph of the same buses and chains, prepared alike, whole or not at all: when a chain refuses its part, the chains before it get their own state back.

§Errors

Returns where and why the state was refused: the bus counts differ, a chain refused its part, or a bus’s alignment does not fit (the buses’ latencies differ from the saving graph’s).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.