pub trait DynamicNode1x1: Send {
    fn process(
        &mut self,
        _input: &[f32],
        _output: &mut [f32],
        _ctx: &DynNode1x1Context
    ); fn set_sample_rate(&mut self, _sample_rate: f32) { ... } fn reset(&mut self) { ... } }
Expand description

This trait allows you to write custom HexoDSP nodes in Rust and provide them at runtime using [crate::NodeConfigurator::set_dynamic_node1x1] or crate::SynthConstructor::set_dynamic_node1x1.

The 1x1 means there is one dedicated input signal and one dedicated output signal. The input signal is accompanied with 4 auxiliary signals using the DynNode1x1Context structure.

There is a trait implementation for FnMut(&[f32], &mut [f32], &DynNode1x1Context) functions, which means you don’t have to implement a full structure yourself and can just pass in closures to crate::SynthConstructor::set_dynamic_node1x1:

 use hexodsp::{SynthConstructor, DynamicNode1x1, DynNode1x1Context};
 use hexodsp::build::*;

 let mut sc = SynthConstructor::new();

 sc.set_dynamic_node1x1(0, Box::new(|inp: &[f32], out: &mut [f32], ctx: &DynNode1x1Context| {
     // Your code here!
 }));

 sc.upload(&out(0).input().ch1(&rust1x1(0).output().sig()));

See also: crate::SynthConstructor::set_dynamic_node1x1 for a more detailed example.

Required Methods

You implement this method with your own custom DSP code.

Provided Methods

The sample rate function sets the sample rate the DSP graph is currently running at.

This is called whenever the DSP in the audio thread is resetted.

Trait Implementations

Returns the “default value” for a type. Read more

Implementors