pub enum Connection {
    Node {
        source: NodeId,
        from_index: Option<usize>,
        from_label: Option<&'static str>,
        sink: NodeId,
        to_index: Option<usize>,
        to_label: Option<&'static str>,
        to_index_offset: usize,
        channels: usize,
        feedback: bool,
    },
    Constant {
        value: Sample,
        sink: Option<NodeId>,
        to_index: Option<usize>,
        to_label: Option<&'static str>,
    },
    GraphOutput {
        source: NodeId,
        from_index: Option<usize>,
        from_label: Option<&'static str>,
        to_index: usize,
        channels: usize,
    },
    GraphInput {
        sink: NodeId,
        from_index: usize,
        to_index: Option<usize>,
        to_label: Option<&'static str>,
        to_index_offset: usize,
        channels: usize,
    },
    Clear {
        node: NodeId,
        input_nodes: bool,
        input_constants: bool,
        output_nodes: bool,
        graph_outputs: bool,
        graph_inputs: bool,
        channel: Option<NodeChannel>,
    },
    GraphInputToOutput {
        graph_id: GraphId,
        from_input_channel: usize,
        to_output_channel: usize,
        channels: usize,
    },
    ClearGraphInputToOutput {
        graph_id: GraphId,
        from_input_channel: Option<usize>,
        to_output_channel: Option<usize>,
        channels: Option<usize>,
    },
}
Expand description

Connection provides a convenient API for creating connections between nodes in a graph. When used for nodes in a running graph, the shadow engine will translate the Connection to a RtConnection which contains the full Path for finding the correct Graph as fast as possible.

A node can have any number of connections to/from other nodes or outputs. Multiple constant values will result in the sum of all the constants.

Variants§

§

Node

Fields

§source: NodeId

Connect from the output of the source node

§from_index: Option<usize>

What output channel from the source node to connect from.

Either from_index or from_label can be used, but index takes precedence if both are set.

§from_label: Option<&'static str>

What output channel from the source node to connect from.

Either from_index or from_label can be used, but index takes precedence if both are set.

§sink: NodeId

Connect to the input of the sink node

§to_index: Option<usize>

What input channel on the sink node to connect to.

Either to_index or to_label can be used, but index takes precedence if both are set. if input_index and input_label are both None, the default is index 0

§to_label: Option<&'static str>

What input channel on the sink node to connect to.

Either to_index or to_label can be used, but index takes precedence if both are set.

§to_index_offset: usize

An offset to the destination, useful if targeting a labelled channel and wanting to connect multiple channels in a row.

§channels: usize

How many channels to connect. Channels will wrap if this value is larger than the number of channels on the sink and/or source nodes. Default: 1.

§feedback: bool

Set to true if this connection should be a feedback connection, meaning gives the values from the previous block, but allows loops in the Graph.

node to node

§

Constant

Fields

§value: Sample

New constant value

§sink: Option<NodeId>

The node whose input constant to set

§to_index: Option<usize>

What input channel to set the constant value of.

Either to_index or to_label can be used, but index takes precedence if both are set. if input_index and input_label are both None, the default is index 0

§to_label: Option<&'static str>

What input channel to set the constant value of.

Either to_index or to_label can be used, but index takes precedence if both are set.

Set a node input constant. This sets the value immediately if the Graph is not running. Otherwise it is equivalent to scheduling a parameter change as soon as possible.

§

GraphOutput

Fields

§source: NodeId

From which node to connect to the graph output.

§from_index: Option<usize>

What output channel from the source node to connect from.

Either from_index or from_label can be used, but index takes precedence if both are set.

§from_label: Option<&'static str>

What output channel from the source node to connect from.

Either from_index or from_label can be used, but index takes precedence if both are set.

§to_index: usize

What channel index of the graph outputs to connect to.

§channels: usize

How many channels to connect. Channels will wrap if this value is larger than the number of channels on the sink and/or source nodes. Default: 1.

node to graph output

§

GraphInput

Fields

§sink: NodeId

To which node a graph input will be connected

§from_index: usize

From what index of the Graph inputs we will connect

§to_index: Option<usize>

What input channel to connect to.

Either to_index or to_label can be used, but index takes precedence if both are set. if input_index and input_label are both None, the default is index 0

§to_label: Option<&'static str>

What input channel to connect to.

Either to_index or to_label can be used, but index takes precedence if both are set. if input_index and input_label are both None, the default is index 0

§to_index_offset: usize

An offset to the destination, useful if targeting a labelled channel and wanting to connect multiple channels in a row.

§channels: usize

How many channels to connect. Channels will wrap if this value is larger than the number of channels on the sink and/or source nodes. Default: 1.

graph input to node

§

Clear

Fields

§node: NodeId

The node whose connections to clear

§input_nodes: bool

If true, clear connections to this node

§input_constants: bool

If true, clear constant input values of this node

§output_nodes: bool

If true, clear connections from this node to other nodes

§graph_outputs: bool

If true, clear connections from this node to the graph output(s)

§graph_inputs: bool

If true, clear connections from the graph inputs to the node

§channel: Option<NodeChannel>

Specifies a specific channel to clear. If None (default), clear all.

Clear connections related to a node

§

GraphInputToOutput

Fields

§graph_id: GraphId

Which graph to operate on

§from_input_channel: usize

The index of the first input channel to connect from

§to_output_channel: usize

The index of the first output channel to connect to

§channels: usize

How many channels to connect

Connect between a graph input and its output directly

§

ClearGraphInputToOutput

Fields

§graph_id: GraphId

Which graph to operate on

§from_input_channel: Option<usize>

The index of the first input channel to connect from. If None, disconnect all.

§to_output_channel: Option<usize>

The index of the first output channel to connect to. If None, disconnect all.

§channels: Option<usize>

How many channels to connect

Clear all or specific connection(s) from a input to output within the same graph

Implementations§

source§

impl Connection

source

pub fn graph_output(source_node: NodeId) -> Self

Create a connection from source_node to a graph output

source

pub fn graph_input(sink_node: NodeId) -> Self

Create a connection from a graph_input to the sink_node

source

pub fn clear_constants(node: NodeId) -> Self

Clear input constants of node

source

pub fn clear_from_nodes(node: NodeId) -> Self

Clear connections from other nodes to this node’s input(s)

source

pub fn clear_to_nodes(node: NodeId) -> Self

Clear connections from the node specified to other nodes

source

pub fn clear_to_graph_outputs(node: NodeId) -> Self

Clear connections from the node to the graph outputs

source

pub fn clear_from_graph_inputs(node: NodeId) -> Self

Clear connections from the graph inputs to the node

source

pub fn from(self, source_node: NodeId) -> Self

Sets the source of a Connection. Only valid for Connection::Node and Connection::GraphOutput. On other variants it does nothing.

source

pub fn to(self, sink_node: NodeId) -> Self

Sets the source of a Connection. Does nothing on a Connection::GraphOutput or Connection::Clear.

source

pub fn to_label(self, label: &'static str) -> Self

Set the channel to connect to by label

source

pub fn tl(self, label: &'static str) -> Self

Shortcut for to_label

source

pub fn to_index(self, index: usize) -> Self

Set the channel to connect to by index

source

pub fn get_from_index(&self) -> Option<usize>

Get the source channel index of the Connection if one is set

source

pub fn get_to_index(&self) -> Option<usize>

Get the sink channel index of the Connection if one is set

source

pub fn ti(self, index: usize) -> Self

Shortcut for to_index

source

pub fn from_channel(self, channel: impl Into<NodeChannel>) -> Self

Set the source channel

source

pub fn to_channel(self, channel: impl Into<NodeChannel>) -> Self

Set the sink channel

source

pub fn to_channel_offset(self, offset: usize) -> Self

Set the sink channel offset

source

pub fn from_index(self, index: usize) -> Self

Set the source channel by index

source

pub fn from_label(self, label: &'static str) -> Self

Set the source channel by label

source

pub fn channels(self, num_channels: usize) -> Self

Set how many channels should be connected together. This is most useful for multi channel connections e.g. stereo -> stereo. Inputs/outputs will wrap if the num_channels value if higher than the number of inputs/outputs available.

source

pub fn feedback(self, activate: bool) -> Self

Set if the connection should be a feedback connection

source

pub fn get_source_node(&self) -> Option<NodeId>

Get the source node address if one is set and the current variant has one.

Trait Implementations§

source§

impl Clone for Connection

source§

fn clone(&self) -> Connection

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Connection

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Connection

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Connection

source§

fn eq(&self, other: &Connection) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Connection

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,