Module hexodsp::synth_constructor
source · [−]Expand description
Provides a high level API to the HexoDSP synthesizer engine.
This module provides you with a simple high level API to build DSP graphs and upload them to an audio thread. With crate::build you also get a simple compile time checked way to construct DSP graphs to upload via SynthConstructor::upload.
use hexodsp::SynthConstructor;
use hexodsp::NodeExecutor;
use hexodsp::build::*;
let mut sc = SynthConstructor::new();
spawn_audio_thread(sc.executor().unwrap());
let oscillator = bosc(0).set().freq(330.0);
let graph = out(0).set().vol(0.2).input().ch1(&oscillator.output().sig());
sc.upload(&graph).unwrap();
// start some frontend loop here, or some GUI or whatever you like....
// Later at runtime you might want to change the oscillator
// frequency from the frontend:
sc.update_params(&bosc(0).set().freq(440.0));
fn spawn_audio_thread(exec: NodeExecutor) {
// Some loop here that interfaces with [NodeExecutor::process] and regularily
// calls [NodeExecutor::process_graph_updates].
}
See also SynthConstructor::new and crate::build.
Structs
A convenient highlevel API to HexoDSP for building custom synthesizers
from HexoDSP nodes.
Enums
Returned by SynthConstructor if some error occured while updating the graph
or changing paramters.