[−][src]Trait dasp_graph::node::Node
The Node
type used within a dasp graph must implement this trait.
The implementation describes how audio is processed from its inputs to outputs.
- Audio sources or inputs may simply ignore the
inputs
field and write their source data directly to theoutput
buffers. - Audio processors, effects or sinks may read from their
inputs
, apply some custom processing and write the result to theiroutput
buffers.
Multiple Node
implementations are provided and can be enabled or disabled via their
associated features.
Example
The following demonstrates how to implement a simple node that sums each of its inputs onto the output.
use dasp_graph::{Buffer, Input, Node}; // Our new `Node` type. pub struct Sum; // Implement the `Node` trait for our new type. impl Node for Sum { fn process(&mut self, inputs: &[Input], output: &mut [Buffer]) { // Fill the output with silence. for out_buffer in output.iter_mut() { out_buffer.silence(); } // Sum the inputs onto the output. for (channel, out_buffer) in output.iter_mut().enumerate() { for input in inputs { let in_buffers = input.buffers(); if let Some(in_buffer) = in_buffers.get(channel) { dasp_slice::add_in_place(out_buffer, in_buffer); } } } } }
Required methods
fn process(&mut self, inputs: &[Input], output: &mut [Buffer])
Process some audio given a list of the node's inputs
and write the result to the output
buffers.
inputs
represents a list of all nodes with direct edges toward this node. Each
Input
within the list can providee a reference to the output
buffers of their corresponding node.
The inputs
may be ignored if the implementation is for a source node. Alternatively, if
the Node
only supports a specific number of input
s, it is up to the user to decide how
they wish to enforce this or provide feedback at the time of graph and edge creation.
This process
method is called by the Processor
as it
traverses the graph during audio rendering.
Implementations on Foreign Types
impl<F> Node for dyn Signal<Frame = F> where
F: Frame<Sample = f32>,
[src]
F: Frame<Sample = f32>,
impl<'a, T> Node for &'a mut T where
T: Node,
[src]
T: Node,
impl<T> Node for Box<T> where
T: Node,
[src]
T: Node,
impl Node for dyn Fn(&[Input], &mut [Buffer])
[src]
impl Node for dyn FnMut(&[Input], &mut [Buffer])
[src]
impl Node for fn(_: &[Input], _: &mut [Buffer])
[src]
Loading content...
Implementors
impl Node for Pass
[src]
impl Node for Sum
[src]
impl Node for SumBuffers
[src]
impl Node for BoxedNode
[src]
impl Node for BoxedNodeSend
[src]
impl<G, T> Node for GraphNode<G, T> where
G: Data<NodeWeight = NodeData<T>> + DataMapMut + Visitable,
&'a G: GraphBase<NodeId = G::NodeId> + IntoNeighborsDirected,
T: Node,
[src]
G: Data<NodeWeight = NodeData<T>> + DataMapMut + Visitable,
&'a G: GraphBase<NodeId = G::NodeId> + IntoNeighborsDirected,
T: Node,
impl<S> Node for Delay<S> where
S: SliceMut<Element = f32>,
[src]
S: SliceMut<Element = f32>,