Module engine

Module engine 

Source
Expand description

Generic DSP engine that pairs a DspGraph implementation with a Runtime, handling graph mounting, parameter diffing, and audio processing.

§Usage

  1. Implement DspGraph for your graph — a pure function that builds Vec<Node> from parameters.
  2. Create an Engine at activation time.
  3. Call Engine::set_params on parameter changes — the engine auto-discovers keyed consts and native node props from the graph and emits only the minimal update batches.
  4. Call Engine::process on every audio block.

§Example

use elemaudio_rs::{el, extra, Node};
use elemaudio_rs::engine::{DspGraph, Engine};
use serde_json::json;

struct MyDelay;

impl DspGraph for MyDelay {
    type Params = f64; // just delay_ms for this example

    fn build(params: &f64) -> Vec<Node> {
        let delay = el::const_with_key("delay", *params);
        let fb = el::const_(0.3);
        let input = el::r#in(json!({"channel": 0}), None);
        vec![extra::stride_delay(json!({"maxDelayMs": 1500}), delay, fb, input)]
    }
}

let engine = Engine::<MyDelay>::new(44100.0, 512, &250.0).unwrap();

Structs§

Engine
Generic DSP engine that owns a Runtime and a mounted graph.
KeyedConst
A keyed const declaration (legacy — auto-discovered by engine).
NativeProp
A native node property declaration (legacy — auto-discovered by engine).

Traits§

DspGraph
A pure graph-building function.