pub struct Instances {
pub key: u64,
pub max: u16,
pub min_gap: f64,
pub policy: OverLimit,
}Expand description
Limits for one sound: at most max voices with the same key play at once, and a
new one starts no sooner than min_gap seconds after the last, so that ten coins
collected together do not sum into distortion.
When max voices already play, policy decides: refuse the new voice, or stop
the oldest or the quietest one with a 5 ms fade. A refused start reports
MixerEvent::Limited; a start within the gap is always refused. Limits are
judged with the mixer’s bound on voices and its priorities when the start is
applied, so scheduled starts are judged at their own frame, and a start refused for
any reason stops no voice and does not begin a gap. Only instances of no higher
priority than the new voice give way to it. Each start is checked against
its own gap, from the sound’s last start. The mixer remembers the last starts of up
to 1024 limited sounds within any 60 seconds; a limited start beyond that is refused.
Fields§
§key: u64Voices with the same key share the limits. Instances::of keys a sound by
its identity, so every voice of that audio counts, also through clones and
Arcs. Keys you pick yourself should be below 2^63; internal audio and event
identities occupy the upper half of the key space.
max: u16Most voices playing at once; 0 for no limit.
min_gap: f64Seconds from one start to the next, 0..=60.
policy: OverLimitImplementations§
Source§impl Instances
impl Instances
Sourcepub fn of(sound: &Audio) -> Self
pub fn of(sound: &Audio) -> Self
Limits keyed by a decoded sound’s identity, which no other audio value shares, even after this one is freed.