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
impl AudioGraph
Sourcepub fn new(layout: ChannelLayout, buses: usize) -> Self
pub fn new(layout: ChannelLayout, buses: usize) -> Self
Creates one clip chain and one track bus per input bus.
Sourcepub const fn layout(&self) -> ChannelLayout
pub const fn layout(&self) -> ChannelLayout
Channel layout every bus and the master run in.
Sourcepub fn buses(&self) -> usize
pub fn buses(&self) -> usize
Number of input buses, each with its own clip chain and track bus.
Sourcepub fn clip_chain_mut(&mut self, bus: usize) -> Option<&mut ProcessorChain>
pub fn clip_chain_mut(&mut self, bus: usize) -> Option<&mut ProcessorChain>
Mutable clip effect chain of bus; None past the last bus.
Sourcepub fn track_bus_mut(&mut self, bus: usize) -> Option<&mut ProcessorChain>
pub fn track_bus_mut(&mut self, bus: usize) -> Option<&mut ProcessorChain>
Mutable track effect chain of bus; None past the last bus.
Sourcepub fn master_mut(&mut self) -> &mut ProcessorChain
pub fn master_mut(&mut self) -> &mut ProcessorChain
Mutable master effect chain.
Sourcepub fn prepare(&mut self, sample_rate: u32, max_block: usize)
pub fn prepare(&mut self, sample_rate: u32, max_block: usize)
Prepares every allocation before realtime processing.
Sourcepub fn latency_samples(&self) -> u32
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.
Sourcepub fn process(
&mut self,
ctx: &ProcessCtx,
inputs: &[&[f32]],
outputs: &mut [&mut [f32]],
)
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.
Sourcepub fn save_state(&self) -> AudioGraphState
pub fn save_state(&self) -> AudioGraphState
Captures every clip, track, and master processor history, and the audio the buses’ alignment holds.
Sourcepub fn load_state(
&mut self,
state: &AudioGraphState,
) -> Result<(), GraphStateError>
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).