pub struct Graph<S>where
S: Sample,{ /* private fields */ }Expand description
A directed acyclic graph of connected DSP blocks.
The graph manages block storage, buffer allocation, and execution ordering. Blocks are processed in topologically sorted order to ensure dependencies are satisfied.
Implementations§
Source§impl<S> Graph<S>where
S: Sample,
impl<S> Graph<S>where
S: Sample,
Sourcepub fn new(
sample_rate: f64,
buffer_size: usize,
num_channels: usize,
) -> Graph<S>
pub fn new( sample_rate: f64, buffer_size: usize, num_channels: usize, ) -> Graph<S>
Create a Graph with a given sample rate, buffer size, and number of channels.
Sourcepub fn context(&self) -> &DspContext
pub fn context(&self) -> &DspContext
Get the underlying DspContext used by a Graph.
Sourcepub fn get_block(&self, id: BlockId) -> Option<&BlockType<S>>
pub fn get_block(&self, id: BlockId) -> Option<&BlockType<S>>
Get a reference to a block by its ID.
Sourcepub fn get_block_mut(&mut self, id: BlockId) -> Option<&mut BlockType<S>>
pub fn get_block_mut(&mut self, id: BlockId) -> Option<&mut BlockType<S>>
Get a mutable reference to a block by its ID.
Sourcepub fn add_block(&mut self, block: BlockType<S>) -> BlockId
pub fn add_block(&mut self, block: BlockType<S>) -> BlockId
Add an arbitrary block to the Graph.
Sourcepub fn add_output_block(&mut self) -> BlockId
pub fn add_output_block(&mut self) -> BlockId
Add an output block to the Graph.
Sourcepub fn connect(
&mut self,
from: BlockId,
from_output: usize,
to: BlockId,
to_input: usize,
)
pub fn connect( &mut self, from: BlockId, from_output: usize, to: BlockId, to_input: usize, )
Form a Connection between two particular blocks.
Sourcepub fn prepare_for_playback(&mut self)
pub fn prepare_for_playback(&mut self)
Prepares the graph for audio processing.
Must be called after all blocks are added and connected, but before
process_buffers. Computes execution order
and pre-allocates buffers.
Sourcepub fn process_buffers(&mut self, output_buffers: &mut [&mut [S]])
pub fn process_buffers(&mut self, output_buffers: &mut [&mut [S]])
Process one buffer’s worth of audio through all blocks.
Executes blocks in topologically sorted order, copying final output to the provided buffers (one per channel).