pub struct EventBank { /* private fields */ }Expand description
Parsed text bank, independent of a mixer or source registry.
Implementations§
Source§impl EventBank
impl EventBank
Sourcepub fn parse(text: &str) -> Result<Self, ParseError>
pub fn parse(text: &str) -> Result<Self, ParseError>
Parses UTF-8 text (at most 1 MiB, 1024 events, 64 source entries per event).
Blank/comment lines are allowed; an empty bank is valid. Every other line is
event NAME sources=A,B [key=value ...]. No whitespace inside values.
Identifiers contain 1..=64 ASCII letters/digits/_/-/..
Unknown/repeated keys and duplicate event names are errors.
| Key | Values / default |
|---|---|
sources | Required comma-separated registered names; duplicates weight entries |
choice | random (default), shuffle, sequence |
gain | Linear min,max or fixed value, finite >=0; default 1 |
pitch | Semitones min,max or fixed, -48..=48; default 0 |
bus | Named mixer bus or master (default) |
priority | 0..=255; default 128 |
max-instances | Concurrent voices across all variants; 0 unlimited (default) |
min-gap | Minimum seconds between admitted starts, 0..=60; default 0 |
policy | refuse (default), oldest, quietest |
loop | off (default), whole, or start,end source frames |
pan | -1..=1, default 0; replaced by spatial placement |
rate | 1/16..=8; default 1 |
fade-in | Linear fade seconds, 0..=60; default 0 |
position | x,y relative 2D position using the mixer’s Space2d |
emitter | x,y,z world position, mutually exclusive with position |
velocity | x,y,z (default zero), requires emitter |
attenuation | model,min,max,rolloff; model is linear, inverse or exponential; requires emitter; mixer defaults |
Sequence wraps in text order. Shuffle draws every entry once per cycle and avoids the previous entry at cycle boundaries when there are >=2 entries. Random samples with replacement. Distinct entries may name the same sound.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn prepare(
&self,
handle: &MixerHandle,
sources: &Sources,
) -> Result<PreparedBank, ParseError>
pub fn prepare( &self, handle: &MixerHandle, sources: &Sources, ) -> Result<PreparedBank, ParseError>
Resolves all references and validates loop regions against every candidate. Resolution errors retain the line/column of the corresponding text token. Preparing again creates independent instance groups; clone the resulting bank or create multiple players from it to share limits.