pub fn instant_compile_ast(
    ast: Box<ASTNode>
) -> Result<(Rc<RefCell<DSPNodeContext>>, Box<DSPFunction>), JITCompileError>
Expand description

This is a little helper function to help you getting started with this library.

If you plan to re-compile your functions and properly track state, I suggest you to explicitly create a DSPNodeTypeLibrary with get_standard_library and a DSPNodeContext for state tracking.

 use synfx_dsp_jit::build::*;
 use synfx_dsp_jit::instant_compile_ast;

 let (ctx, mut fun) = instant_compile_ast(
     op_add(literal(11.0), var("in1"))
 ).expect("No compile error");

 fun.init(44100.0, None); // Sample rate and optional previous DSPFunction

 let (sig1, sig2, res) = fun.exec_2in_2out(31.0, 10.0);

 // The result should be 11.0 + 31.0 == 42.0
 assert!((res - 42.0).abs() < 0.0001);

 // Yes, unfortunately you need to explicitly free this.
 // Because DSPFunction might be handed around to other threads.
 ctx.borrow_mut().free();