# wavegraph-dsp
[![Build status][ci-badge]][ci]
[![Project Chat][chat-image]][chat-link]
`wavegraph-dsp` runs compiled audio patches on caller-owned buffers without a heap.
It re-exports `Event`, `Op`, `Port`, `Process`, and `ProcessContext` from
[`wavegraph-core`][core]. Instrument crates depend on that interface directly.
An application supplies instances and selects the sample format and DSP
implementation.
## Rendering a compiled patch
The following program plays the waveform monosynth through a half-gain stage.
The note starts at frame 2. Its state carries over to the next block.
```rust
use wavegraph_dsp::{Event, bytecode::Program, dsp::Software};
use wavegraph_monosynth::{Message, Monosynth, Tuning, Waveform};
use wavegraph_sample::I24;
const TUNING: Tuning = Tuning::new(24_000_000, 544).unwrap();
let mut voice = Monosynth::new(&TUNING);
let program = [
1, // version
1, 0, 0, 1, // call object 0 with no signal inputs and one output (bus 0)
2, 0, 64, // scale bus 0 by 64/128, producing bus 1
];
let mut objects: [&mut dyn wavegraph_dsp::Process<Message, I24>; 1] = [&mut voice];
let schedule = Program::<2>::decode(&program).unwrap();
let mut patch = schedule.bind(&mut objects).unwrap();
let notes = [
Event { frame: 2, port: 0, message: Message::Waveform(Waveform::Square) },
Event { frame: 2, port: 0, message: Message::NoteOn { note: 69, velocity: 100 } },
];
let mut buses = [[I24::default(); 256]; 2];