Skip to main content

RewireDspGraph

Type Alias RewireDspGraph 

Source
pub type RewireDspGraph<T> = DspGraph<T, RewireProcessorChannel>;
Expand description

Type alias for a graph with rewiring support

Aliased Type§

pub struct RewireDspGraph<T> { /* private fields */ }

Implementations§

Source§

impl<T: Sample> RewireDspGraph<T>

Source

pub fn rewire( &mut self, edge_index: EdgeIndex, rewire_mapping: &[(usize, usize)], ) -> Result<(), AudioGraphError>

Rewires an existing connection in the graph to use a different channel mapping between the edge’s source and destination nodes.

NOT realtime safe

The rewire_mapping parameter is a slice of tuples where each tuple defines a channel mapping in the form (source_channel, destination_channel).

Note: Mapping multiple source channels to the same destination channel returns an error.

§Example
use audiograph::{FrameSize, GraphNode, MultiChannelBuffer, NoOp, RewireDspGraph};

let frame_size = FrameSize(1024);

let mut dsp_graph = RewireDspGraph::<f32>::new(4, frame_size, None);

let node1 = dsp_graph
    .add_processor(
        NoOp {},
        MultiChannelBuffer::new(4, frame_size), // 4 output channels
    )
    .unwrap();

let node2 = dsp_graph
    .add_processor(
        NoOp {},
        MultiChannelBuffer::new(4, frame_size), // 4 output channels
    )
    .unwrap();

// Connect nodes with default channel selection (i.e., all channels in order)
dsp_graph
    .connect(GraphNode::Input, node1.into(), None)
    .unwrap();

let edge = dsp_graph.connect(node1.into(), node2.into(), None).unwrap();

dsp_graph
    .connect(node2.into(), GraphNode::Output, None)
    .unwrap();

// Rewire the edge to swap channels 0 and 1, while keeping channels 2 and 3 the same
dsp_graph
    .rewire(edge, &[(0, 1), (1, 0), (2, 2), (3, 3)])
    .unwrap();
Source

pub fn remove_rewire( &mut self, edge_index: EdgeIndex, ) -> Result<(), AudioGraphError>

Removes rewiring from an existing connection, reverting to the default channel selection (i.e. all channels connected)

NOT realtime-safe

Source

pub fn connect_rewired( &mut self, from: GraphNode, to: GraphNode, wiring: &[(usize, usize)], ) -> Result<EdgeIndex, AudioGraphError>

Connects two nodes and creates a rewired mapping in one step

NOT realtime-safe

See RewireDspGraph::connect and RewireDspGraph::rewire for details.