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>>,
backend_factory: Arc<BackendFactory<T>>,
) -> Self
pub fn new( factory: Arc<NodeFactory<T, BUF_SIZE>>, backend_factory: 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 set_node_backend(&mut self, idx: usize, name: String)
pub fn set_node_backend(&mut self, idx: usize, name: String)
Assign a named backend to the node at the given index.
During build, the backend is created via the
builder’s BackendFactory and passed to
the node’s Node::resolve_backend.
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 set_default_backend(
&mut self,
name: String,
params: HashMap<String, ParamValue>,
)
pub fn set_default_backend( &mut self, name: String, params: HashMap<String, ParamValue>, )
Set the default backend name and parameters. Nodes without an explicit
backend in [NodeDef::backend] will use this during build.
Sourcepub fn default_backend_name(&self) -> Option<&String>
pub fn default_backend_name(&self) -> Option<&String>
Get the default backend name, if set.
Sourcepub fn set_sample_rate(&mut self, sr: f32)
pub fn set_sample_rate(&mut self, sr: f32)
Set the sample rate for this builder.
Sourcepub fn set_clock_tx(&mut self, tx: ActorRef<ClockTick>)
pub fn set_clock_tx(&mut self, tx: ActorRef<ClockTick>)
Set the clock tick channel (audio → control).
Sourcepub fn backend_factory(&self) -> &Arc<BackendFactory<T>>
pub fn backend_factory(&self) -> &Arc<BackendFactory<T>>
Access the shared backend factory.
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 build(self) -> Result<Graph<T, BUF_SIZE>, BuildError>
pub fn build(self) -> Result<Graph<T, BUF_SIZE>, BuildError>
Build the graph.
Creates backends for nodes that have a backend name set (via
[NodeDef::backend] or the builder’s default). Finds the active
(driver) node and stores its index for Graph::run.