[−][src]Struct dasp_graph::Processor
State related to the processing of an audio graph of type G
.
The Processor allows for the re-use of resources related to traversal and requesting audio from the graph. This makes it easier to avoid dynamic allocation within a high-priority audio context.
Example
use dasp_graph::{Node, NodeData}; use petgraph; // Chose a type of graph for audio processing. type Graph = petgraph::graph::DiGraph<NodeData<MyNode>, (), u32>; // Create a short-hand for our processor type. type Processor = dasp_graph::Processor<Graph>; fn main() { // Create a graph and a processor with some suitable capacity to avoid dynamic allocation. let max_nodes = 1024; let max_edges = 1024; let mut g = Graph::with_capacity(max_nodes, max_edges); let mut p = Processor::with_capacity(max_nodes); // Add some nodes and edges... // Process all nodes within the graph that output to the node at `n_id`. p.process(&mut g, n_id); }
Implementations
impl<G> Processor<G> where
G: Visitable,
[src]
G: Visitable,
pub fn with_capacity(max_nodes: usize) -> Self where
G::Map: Default,
[src]
G::Map: Default,
Construct a new graph processor from the given maximum anticipated node count.
As long as this node count is not exceeded, the Processor should never require dynamic allocation following construction.
pub fn process<T>(&mut self, graph: &mut G, node: G::NodeId) where
G: Data<NodeWeight = NodeData<T>> + DataMapMut,
&'a G: GraphBase<NodeId = G::NodeId> + IntoNeighborsDirected,
T: Node,
[src]
G: Data<NodeWeight = NodeData<T>> + DataMapMut,
&'a G: GraphBase<NodeId = G::NodeId> + IntoNeighborsDirected,
T: Node,
Process audio through the subgraph ending at the node with the given ID.
Specifically, this traverses nodes in depth-first-search post order where the edges of
the graph are reversed. This is equivalent to the topological order of all nodes that are
connected to the inputs of the given node
. This ensures that all inputs of each node are
visited before the node itself.
The Node::process
method is called on each node as they are visited in the traversal.
Upon returning, the buffers of each visited node will contain the audio processed by their respective nodes.
Supports all graphs that implement the necessary petgraph traits and whose nodes are of
type NodeData<T>
where T
implements the Node
trait.
Panics if there is no node for the given index.
Auto Trait Implementations
impl<G> RefUnwindSafe for Processor<G> where
<G as Visitable>::Map: RefUnwindSafe,
<G as GraphBase>::NodeId: RefUnwindSafe,
<G as Visitable>::Map: RefUnwindSafe,
<G as GraphBase>::NodeId: RefUnwindSafe,
impl<G> Send for Processor<G> where
<G as Visitable>::Map: Send,
<G as GraphBase>::NodeId: Send,
<G as Visitable>::Map: Send,
<G as GraphBase>::NodeId: Send,
impl<G> !Sync for Processor<G>
impl<G> Unpin for Processor<G> where
<G as Visitable>::Map: Unpin,
<G as GraphBase>::NodeId: Unpin,
<G as Visitable>::Map: Unpin,
<G as GraphBase>::NodeId: Unpin,
impl<G> UnwindSafe for Processor<G> where
<G as Visitable>::Map: UnwindSafe,
<G as GraphBase>::NodeId: UnwindSafe,
<G as Visitable>::Map: UnwindSafe,
<G as GraphBase>::NodeId: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<S, T> Duplex<S> for T where
T: FromSample<S> + ToSample<S>,
T: FromSample<S> + ToSample<S>,
impl<T> From<T> for T
[src]
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> ToSample<U> for T where
U: FromSample<T>,
U: FromSample<T>,
fn to_sample_(self) -> U
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,