Expand description
Named sound events, parsed and prepared on the control thread (events feature).
One definition per line: event footstep sources=left,right choice=shuffle gain=0.8,1 pitch=-1,1 max-instances=2 min-gap=0.08 bus=effects.
Names are case-sensitive ASCII identifiers (letters, digits, _, -, .).
# begins a comment. See EventBank::parse for the complete grammar.
Register decoded sounds in Sources; optional helpers render SFX and scores
once, before playback. EventBank::prepare resolves every source and bus and
checks every loop region. No parsing, file access or synthesis runs on audio.
A prepared bank belongs to one mixer. Its players share per-event instance
limits, including across variants, but have independent seeded selection state.
Selection/gain/pitch are deterministic per event name and seed, independent of
other events and the mixer’s RNG. Errors returned by play do not consume that
state. A successfully queued request consumes it even if audio later reports
super::MixerEvent::Limited or super::MixerEvent::Rejected. Voice IDs and
admission depend on other mixer activity. Poll mixer events normally to reclaim
finished voices and distinguish submission from application. All event methods
are control-thread operations and may allocate.
use audiobox::events::{EventBank, Sources};
use audiobox::mixer::{Mixer, MixerConfig};
use audiobox::Audio;
let (mut mixer, mut handle) = Mixer::new(MixerConfig::default())?;
let mut sources = Sources::default();
sources.insert("click", Audio::new(vec![vec![0.1; 100]], 48_000)?)?;
let bank = EventBank::parse("event ui.click sources=click gain=0.5,0.8")?;
let mut player = bank.prepare(&handle, &sources)?.player(42);
let started = player.play(&mut handle, "ui.click")?;Structs§
- Event
Bank - Parsed text bank, independent of a mixer or source registry.
- Event
Player - Seeded event selection state. Use returned voice IDs with normal mixer commands.
- Parse
Error - Stable error code and one-based line/character column of an offending token.
Syntax errors use
Syntax, out-of-range values/unresolved references useInvalidArgument, and text/event/source-entry bounds useLimitExceeded. - Prepared
Bank - Resolved, immutable, mixer-bound events. Clones share sources and instance keys.
- Sources
- Source registry. Insertion and optional synthesis happen on the control thread.
Prepared banks retain
Arcs, so the registry may be dropped after preparation. - Trigger
- Per-request scheduling and spatial override.
- Triggered
- Successfully queued request, with selected parameters for replay/debugging.
Enums§
- Placement
- Optional per-request placement, replacing the event’s spatial defaults.