Skip to main content

Router

Trait Router 

Source
pub trait Router<T: Transcendental, const BUF_SIZE: usize>: Node<T, BUF_SIZE> {
    // Required methods
    fn route(
        &mut self,
        ctx: &RenderContext,
        inputs: &[&[T; BUF_SIZE]],
    ) -> ProcessResult<()>;
    fn num_route_inputs(&self) -> usize;
    fn num_route_outputs(&self) -> usize;
    fn set_connection(
        &mut self,
        from: usize,
        to: usize,
        gain: T,
    ) -> ProcessResult<()>;
    fn remove_connection(&mut self, from: usize, to: usize) -> ProcessResult<()>;
    fn routing_matrix(&self) -> Vec<Vec<(usize, T)>>;
}
Expand description

Signal router — N inputs, M outputs, configurable matrix.

Unlike Processor::process(), which performs DSP, Router only redistributes input signals to outputs. The router manages its own output ports via Node::output_port_mut().

TapeLoop is obtained not through this trait, but through the graph resource registry — see GraphBuilder::add_resource() and Node::init().

Required Methods§

Source

fn route( &mut self, ctx: &RenderContext, inputs: &[&[T; BUF_SIZE]], ) -> ProcessResult<()>

Route one block.

The implementation must read signals from inputs and write the results to its output ports (via self.output_port_mut(i)).

Source

fn num_route_inputs(&self) -> usize

Number of input ports for routing.

Source

fn num_route_outputs(&self) -> usize

Number of output ports for routing.

Source

fn set_connection( &mut self, from: usize, to: usize, gain: T, ) -> ProcessResult<()>

Set up a connection: route input from to output to with gain coefficient gain.

Source

fn remove_connection(&mut self, from: usize, to: usize) -> ProcessResult<()>

Remove a connection (zero the coefficient).

Source

fn routing_matrix(&self) -> Vec<Vec<(usize, T)>>

Get the current routing matrix: for each output — a list of inputs with gains.

Trait Implementations§

Source§

impl<T, const BUF_SIZE: usize> Processable<T, BUF_SIZE> for Box<dyn Router<T, BUF_SIZE>>
where T: Transcendental,

Source§

fn process_block( &mut self, ctx: &RenderContext, _tick: &ClockTick, ) -> ProcessResult<()>

Process one block of signal samples. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§