pub struct AudioGraph<C> { /* private fields */ }Implementations§
Source§impl<C: 'static> AudioGraph<C>
impl<C: 'static> AudioGraph<C>
pub fn max_block_frames(&self) -> usize
Sourcepub fn graph_in_node(&self) -> NodeID
pub fn graph_in_node(&self) -> NodeID
The ID of the graph input node
Sourcepub fn graph_out_node(&self) -> NodeID
pub fn graph_out_node(&self) -> NodeID
The ID of the graph output node
Sourcepub fn add_node(
&mut self,
num_inputs: usize,
num_outputs: usize,
node: impl AudioNode<C>,
) -> NodeID
pub fn add_node( &mut self, num_inputs: usize, num_outputs: usize, node: impl AudioNode<C>, ) -> NodeID
Add a new [Node] the the audio graph.
This will return the globally unique ID assigned to this node.
Sourcepub fn node(&self, node_id: NodeID) -> Option<&Box<dyn AudioNode<C>>>
pub fn node(&self, node_id: NodeID) -> Option<&Box<dyn AudioNode<C>>>
Get an immutable reference to the node.
This will return None if a node with the given ID does not
exist in the graph.
Sourcepub fn node_mut(
&mut self,
node_id: NodeID,
) -> Option<&mut Box<dyn AudioNode<C>>>
pub fn node_mut( &mut self, node_id: NodeID, ) -> Option<&mut Box<dyn AudioNode<C>>>
Get a mutable reference to the node.
This will return None if a node with the given ID does not
exist in the graph.
Sourcepub fn node_info(&self, node_id: NodeID) -> Option<&NodeEntry<NodeWeight<C>>>
pub fn node_info(&self, node_id: NodeID) -> Option<&NodeEntry<NodeWeight<C>>>
Get info about a node.
This will return None if a node with the given ID does not
exist in the graph.
Sourcepub fn remove_node(&mut self, node_id: NodeID) -> Result<Vec<EdgeID>, ()>
pub fn remove_node(&mut self, node_id: NodeID) -> Result<Vec<EdgeID>, ()>
Remove the given node from the graph.
This will automatically remove all edges from the graph that were connected to this node.
On success, this returns a list of all edges that were removed from the graph as a result of removing this node.
This will return an error if a node with the given ID does not exist in the graph, or if the ID is of the graph input or graph output node.
Sourcepub fn nodes<'a>(&'a self) -> impl Iterator<Item = &'a NodeEntry<NodeWeight<C>>>
pub fn nodes<'a>(&'a self) -> impl Iterator<Item = &'a NodeEntry<NodeWeight<C>>>
Get a list of all the existing nodes in the graph.
Sourcepub fn edges<'a>(&'a self) -> impl Iterator<Item = &'a Edge>
pub fn edges<'a>(&'a self) -> impl Iterator<Item = &'a Edge>
Get a list of all the existing edges in the graph.
Sourcepub fn set_num_inputs(
&mut self,
node_id: NodeID,
num_inputs: usize,
) -> Result<Vec<EdgeID>, ()>
pub fn set_num_inputs( &mut self, node_id: NodeID, num_inputs: usize, ) -> Result<Vec<EdgeID>, ()>
Set the number of input ports for a particular node in the graph.
This will return an error if a node with the given ID does not exist in the graph, or if the ID is of the graph input node.
Sourcepub fn set_num_outputs(
&mut self,
node_id: NodeID,
num_outputs: usize,
) -> Result<Vec<EdgeID>, ()>
pub fn set_num_outputs( &mut self, node_id: NodeID, num_outputs: usize, ) -> Result<Vec<EdgeID>, ()>
Set the number of output ports for a particular node in the graph.
This will return an error if a node with the given ID does not exist in the graph, or if the ID is of the graph output node.
Sourcepub fn add_edge(
&mut self,
src_node: NodeID,
src_port: impl Into<OutPortIdx>,
dst_node: NodeID,
dst_port: impl Into<InPortIdx>,
check_for_cycles: bool,
) -> Result<EdgeID, AddEdgeError>
pub fn add_edge( &mut self, src_node: NodeID, src_port: impl Into<OutPortIdx>, dst_node: NodeID, dst_port: impl Into<InPortIdx>, check_for_cycles: bool, ) -> Result<EdgeID, AddEdgeError>
Add an Edge (port connection) to the graph.
src_node_id- The ID of the source node.src_port_idx- The index of the source port. This must be an output port on the source node.dst_node_id- The ID of the destination node.dst_port_idx- The index of the destination port. This must be an input port on the destination node.check_for_cycles- Iftrue, then this will run a check to see if adding this edge will create a cycle in the graph, and return an error if it does.
If successful, this returns the globally unique identifier assigned to this edge.
If this returns an error, then the audio graph has not been modified.
Sourcepub fn remove_edge(&mut self, edge_id: EdgeID) -> bool
pub fn remove_edge(&mut self, edge_id: EdgeID) -> bool
Remove the given Edge (port connection) from the graph.
If the edge did not exist in the graph, then false will be
returned.