Struct hexodsp::chain_builder::MatrixCellChain
source · [−]pub struct MatrixCellChain {
chain: Vec<MatrixChainLink>,
error: Option<ChainError>,
dir: CellDir,
param_idx: usize,
}
Expand description
A DSP chain builder for the crate::Matrix.
This is an extremely easy API to create and place new DSP chains into the crate::Matrix. It can be used by frontends to place DSP chains on user request or it can be used by test cases to quickly fill the hexagonal Matrix.
use hexodsp::*;
let mut chain = MatrixCellChain::new(CellDir::BR);
chain.node_out("sin", "sig")
.set_denorm("freq", 220.0)
.node_io("amp", "inp", "sig")
.set_denorm("att", 0.5)
.node_inp("out", "ch1");
// use crate::nodes::new_node_engine;
let (node_conf, _node_exec) = new_node_engine();
let mut matrix = Matrix::new(node_conf, 7, 7);
chain.place(&mut matrix, 2, 2).expect("no error in this case");
Fields
chain: Vec<MatrixChainLink>
error: Option<ChainError>
dir: CellDir
param_idx: usize
Implementations
sourceimpl MatrixCellChain
impl MatrixCellChain
sourcepub fn new(dir: CellDir) -> Self
pub fn new(dir: CellDir) -> Self
Create a new MatrixCellChain with the given placement direction.
The direction is used to guide the placement of the cells.
fn output_dir(&self) -> CellDir
fn input_dir(&self) -> CellDir
sourcepub fn params_for_idx(&mut self, idx: usize) -> &mut Self
pub fn params_for_idx(&mut self, idx: usize) -> &mut Self
Sets the current parameter cell by chain index.
sourcepub fn set_denorm(&mut self, param: &str, denorm: f32) -> &mut Self
pub fn set_denorm(&mut self, param: &str, denorm: f32) -> &mut Self
Sets the denormalized value of the current parameter cell’s parameter.
The current parameter cell is set automatically when a new node is added. Alternatively you can use MatrixCellChain::params_for_idx to set the current parameter cell.
sourcepub fn set_norm(&mut self, param: &str, norm: f32) -> &mut Self
pub fn set_norm(&mut self, param: &str, norm: f32) -> &mut Self
Sets the normalized value of the current parameter cell’s parameter.
The current parameter cell is set automatically when a new node is added. Alternatively you can use MatrixCellChain::params_for_idx to set the current parameter cell.
sourcepub fn set_atom(&mut self, param: &str, at: SAtom) -> &mut Self
pub fn set_atom(&mut self, param: &str, at: SAtom) -> &mut Self
Sets the atom value of the current parameter cell’s parameter.
The current parameter cell is set automatically when a new node is added. Alternatively you can use MatrixCellChain::params_for_idx to set the current parameter cell.
sourcepub fn spawn_cell_from_node_id_name(
&mut self,
node_id_name: &str
) -> Option<Cell>
pub fn spawn_cell_from_node_id_name(
&mut self,
node_id_name: &str
) -> Option<Cell>
Utility function for creating crate::Cell for this chain.
sourcepub fn add_link(&mut self, cell: Cell)
pub fn add_link(&mut self, cell: Cell)
Utility function to add a pre-built crate::Cell as next link.
This also sets the current parameter cell.
sourcepub fn node(&mut self, node_id: &str) -> &mut Self
pub fn node(&mut self, node_id: &str) -> &mut Self
Place a new node in the chain without any inputs or outputs. This is of limited use in this API, but might makes a few corner cases easier in test cases.
sourcepub fn node_out(&mut self, node_id: &str, out: &str) -> &mut Self
pub fn node_out(&mut self, node_id: &str, out: &str) -> &mut Self
Place a new node in the chain with the given output assigned.
sourcepub fn node_inp(&mut self, node_id: &str, inp: &str) -> &mut Self
pub fn node_inp(&mut self, node_id: &str, inp: &str) -> &mut Self
Place a new node in the chain with the given input assigned.
Trait Implementations
sourceimpl Clone for MatrixCellChain
impl Clone for MatrixCellChain
sourcefn clone(&self) -> MatrixCellChain
fn clone(&self) -> MatrixCellChain
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more