macro_rules! stateless_dsp_node_type { ($node_type: ident => $func_name: ident $jit_name: literal $signature: literal doc $doc: literal inputs $($idx: literal $inp: literal)* outputs $($idxo: literal $out: literal)*) => { ... }; }
Expand description
This macro can help you defining new stateless DSP nodes.
use synfx_dsp_jit::*;
extern "C" fn process_mul2(v: f64) -> f64 {
v * 2.0
}
synfx_dsp_jit::stateless_dsp_node_type! {
Mul2NodeType => process_mul2 "mul2" "vr"
doc
"A simple multiplication by 2.0. Using '*' is simpler thought..."
inputs
0 ""
outputs
0 ""
}
// Then use the type by adding it:
fn make_library() -> DSPNodeTypeLibrary {
let mut lib = DSPNodeTypeLibrary::new();
lib.add(Mul2NodeType::new_ref());
lib
}
The "vr"
is a string that specifies the signature of the function. Following characters
are available:
- “v” - A floating point value
- “D” - The global crate::DSPState pointer
- “M” - A pointer to the multi return value array, of type
*mut [f64; 5]
. These can be accessed by the variables “%1” to “%5” after the call. - “r” - Must be specified as last one, defines that this function returns something.