Expand description
Graph
is the audio graph, the core of Knyst. Implement Gen
and you can be a Node
.
To build an audio graph, add generators (anything implementing the Gen
trait) to a graph and add connections between them.
let graph_settings = GraphSettings {
block_size: 64,
sample_rate: 44100.,
num_outputs: 2,
..Default::default()
};
let mut graph = Graph::new(graph_settings);
// Adding a node gives you an address to that node
let sine_node_address = graph.push(WavetableOscillatorOwned::new(Wavetable::sine()));
// Connecting the node to the graph output
graph.connect(sine_node_address.to_graph_out())?;
// You need to commit changes if the graph is running.
graph.commit_changes();
To produce an output from the Graph
we need to turn it into a node. If
you want to listen to the graph output the easiest way is to use and audio
backend. Have a look at RunGraph
if you want to do non-realtime
synthesis or implement your own backend.
Re-exports
pub use crate::node_buffer::NodeBufferRef;
pub use connection::Connection;
pub use run_graph::RunGraph;
pub use run_graph::RunGraphSettings;
Modules
- Connecting nodes/
Gen
s in a Graph is fundamentally done through aConnection
. Additionally, aNodeId
has convenience functions to generateConnection
s and theConnectionBundle
API is often more convenient and ergonomic.
Structs
- Convenience struct to create a
Gen
from a closure. - Convenience struct for the notation
GraphInput::to(node)
- Pass to
Graph::new
to set the options the Graph is created with in an ergonomic and clear way. - Multiply two inputs together and produce one output.
- Handle to a Mult.
- Handle to a NaiveSine.
- Multiple changes to the input values of a certain node. See
Change
for what kinds of changes can be scheduled. All methods return Self so it can be chained: - A handle to an address to a specific node. This handle will be updated with the node key and the graph id once those are available. This means that a handle can be created before the node is inserted into a
Graph
- A parameter (input constant) change to be scheduled on a
Graph
. - An address to a specific Node. The graph_id is constant indepentently of where the graph is (inside some other graph), so it always points to a specific Node in a specific Graph.
- Bundle multiple changes to multiple nodes. This is usually required to be certain that they get applied in the same frame, except if using absolute time.
Enums
- Types of changes that can be scheduled for a node in a Graph.
- Error freeing a node in a Graph
- Describes the oversampling applied to a graph
- Error pushing a new node (Gen or Graph) to a Graph
- Used to denote a relative value of an unsigned type, essentially adding a sign.
- Used to specify a time when a parameter change should be applied.
- Newtype for using a
Time
as an offset.
Traits
- This trait is not meant to be implemented by users. In almost all situations you instead want to implement the
Gen
trait.
Functions
- Alias for
ClosureGen::new
. SeeClosureGen
for more information.
Type Aliases
- The graph consists of (simplified)