pub struct GraphBuilder<T: Transcendental, const BUF_SIZE: usize> { /* private fields */ }Expand description
Mutable builder for an immutable signal graph.
§Node factory
The builder holds an Arc<NodeFactory> for constructing nodes by
type name, provided at construction via GraphBuilder::new.
Implementations§
Source§impl<T: Transcendental, const BUF_SIZE: usize> GraphBuilder<T, BUF_SIZE>
impl<T: Transcendental, const BUF_SIZE: usize> GraphBuilder<T, BUF_SIZE>
Sourcepub fn new(
factory: Arc<NodeFactory<T, BUF_SIZE>>,
backends: Arc<BackendFactory<T>>,
) -> Self
pub fn new( factory: Arc<NodeFactory<T, BUF_SIZE>>, backends: Arc<BackendFactory<T>>, ) -> Self
Create a new empty graph builder without a node factory.
Sourcepub fn add_node(
&mut self,
type_name: &str,
params: &Params,
) -> Result<usize, RegistryError>
pub fn add_node( &mut self, type_name: &str, params: &Params, ) -> Result<usize, RegistryError>
Add a node by type name using the internal factory.
The type must have been registered in the factory before calling this method.
Returns the index of the newly added node.
§Errors
Returns RegistryError if no factory is set or the type name
is not registered.
Sourcepub fn add_node_with_id(
&mut self,
type_name: &str,
params: &Params,
id: NodeId,
) -> Result<usize, RegistryError>
pub fn add_node_with_id( &mut self, type_name: &str, params: &Params, id: NodeId, ) -> Result<usize, RegistryError>
Sourcepub fn add_resource(&mut self, resource: GraphResource)
pub fn add_resource(&mut self, resource: GraphResource)
Register a named resource (tape loop, buffer, etc.).
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes added to the builder so far.
Sourcepub fn backend_factory(&self) -> &Arc<BackendFactory<T>>
pub fn backend_factory(&self) -> &Arc<BackendFactory<T>>
Access the shared backend factory (for building with external configs).
Sourcepub fn add_source(&mut self, source: Box<dyn Source<T, BUF_SIZE>>) -> usize
pub fn add_source(&mut self, source: Box<dyn Source<T, BUF_SIZE>>) -> usize
Add a source node and return its index.
Sourcepub fn add_processor(
&mut self,
processor: Box<dyn Processor<T, BUF_SIZE>>,
) -> usize
pub fn add_processor( &mut self, processor: Box<dyn Processor<T, BUF_SIZE>>, ) -> usize
Add a processor node and return its index.
Sourcepub fn add_sink(&mut self, sink: Box<dyn Sink<T, BUF_SIZE>>) -> usize
pub fn add_sink(&mut self, sink: Box<dyn Sink<T, BUF_SIZE>>) -> usize
Add a sink node and return its index.
Sourcepub fn add_router(&mut self, router: Box<dyn Router<T, BUF_SIZE>>) -> usize
pub fn add_router(&mut self, router: Box<dyn Router<T, BUF_SIZE>>) -> usize
Add a Router node (N→M configurable routing, no DSP).
Sourcepub fn connect_signal(
&mut self,
from_node: usize,
from_port: usize,
to_node: usize,
to_port: usize,
)
pub fn connect_signal( &mut self, from_node: usize, from_port: usize, to_node: usize, to_port: usize, )
Connect signal ports (audio data).
Sourcepub fn connect_control(
&mut self,
from_node: usize,
from_port: usize,
to_node: usize,
to_port: usize,
)
pub fn connect_control( &mut self, from_node: usize, from_port: usize, to_node: usize, to_port: usize, )
Connect control ports (modulation values).
Sourcepub fn connect_clock(
&mut self,
from_node: usize,
from_port: usize,
to_node: usize,
to_port: usize,
)
pub fn connect_clock( &mut self, from_node: usize, from_port: usize, to_node: usize, to_port: usize, )
Connect clock ports (timing events).
Sourcepub fn connect_feedback(
&mut self,
from_node: usize,
from_port: usize,
to_node: usize,
to_port: usize,
)
pub fn connect_feedback( &mut self, from_node: usize, from_port: usize, to_node: usize, to_port: usize, )
Connect feedback ports (delay lines, state carryover).
Sourcepub fn with_backend(
self,
backend_name: &str,
params: HashMap<String, ParamValue>,
) -> Self
pub fn with_backend( self, backend_name: &str, params: HashMap<String, ParamValue>, ) -> Self
Configure an audio backend for this builder.
When set, build looks for a driver node in the graph
and auto-starts it with a command queue and the given audio backend.
Without this method, the graph is purely structural (no audio I/O,
no command queue).
Configure an audio backend for this builder.
Params are passed blindly to the backend factory — keys like
"sample_rate", "buffer_size", "channels" are interpreted
by each backend constructor.
Sourcepub fn build(self) -> Result<Graph<T, BUF_SIZE>, BuildError>
pub fn build(self) -> Result<Graph<T, BUF_SIZE>, BuildError>
Build the graph.
If with_backend was called before, the builder
auto-starts a driver node with a command queue and the configured
audio backend. Otherwise the graph is purely structural (no audio I/O,
no command queue).