Expand description
Headless driver for truce plugins.
Instantiate a plugin, feed it scripted audio + events for a fixed duration, capture the output. Used by:
- Tests via
truce-test- adds assertion helpers on top of the capturedDriverResult. - The standalone host’s offline-render path -
cargo truce run --no-playbackparses CLI flags into anInputSource::Buffer+Script, runsPluginDriver, writes the captured audio out as WAV. - Plugin authors writing custom
main.rsbins - batch CI renders, demo audio generation, preset rendering pipelines.
No cpal, no midir, no live-audio plumbing. The driver does:
P::create()→init()→reset()→ paramset_sample_ratesnap_smoothers.
- Apply
state_filebytes viaplugin.load_state(...). - Run the
setupclosure (&mut Plugin). - Loop blocks: pull script events into the block window, run
plugin.process(...), append the output. - Capture meters / output events / per-block snapshots
according to
CaptureSpec.
See PluginDriver for the builder surface.
ⓘ
use std::time::Duration;
use truce_driver::{InputSource, PluginDriver};
let result = PluginDriver::<MyPlugin>::new()
.sample_rate(48_000.0)
.duration(Duration::from_secs(2))
.input(InputSource::Constant(0.5))
.set_param(MyParamId::Gain, 0.7)
.script(|s| {
s.note_on(60, 0.8);
s.wait_ms(500);
s.note_off(60);
})
.run();Structs§
- Capture
Spec - Driver
Result - Captured audio + metadata + plugin instance from a
PluginDriverrun. - Plugin
Driver - Script
- Sample-accurate sequence of events fed to the plugin during a
run. Cursor advances via
wait_ms/wait_samples; events land at the current cursor position. - Setup
Context - Context passed to the
PluginDriver::setupclosure. Carries the driver state that’s been resolved by the time setup runs - in particular the auto-detected channel count, which would otherwise be invisible to the closure (the user’s&mut Pdoesn’t know). - Transport
Spec - Transport state visible to the plugin’s
ProcessContext.
Enums§
- Input
Source - What audio gets fed into the plugin’s input bus each block.
- Meter
Capture - Meter
Readings