Skip to main content

Module scene

Module scene 

Source
Expand description

The sound scene: the layer above the Device that plays sound effects.

  • 256 effects. Each one walks its effect’s timeline and starts every sound whose start time falls in the frame, with a random variant and a random pitch, at the volume variant × effect × kind. When all its sounds have ended, the effect frees itself (and the 3D effect that started it).
  • 4,096 effects in the world. Each has a position or a list of emitters. Every update takes the loudest emitter (the volume falls in a straight line from the inner radius to the radius, plus the listener’s reach), starts the effect when it can be heard, stops it when it cannot, and passes the volume on.
  • Kinds of sound: 1 interface, 2 music, 3 ambient, 4 effects (kind 0 never plays). Each kind has a volume (by default 100, 50, 100 and 100) and can be paused.

Handles are encoded as in the original: an effect is index·2 | counter<<9, an effect in the world index·2 | 1 | counter<<13. A stale handle does nothing. See Audio.

Original: Audio::Scene in the Runtime.

Modules§

sound_type
The kinds of sound. Each kind has its own volume in the options. Kind 0 never plays.

Structs§

Effect
A SoundEffect with its decoded buffers (per sound, per variant).
EffectCache
Loads each effect once.
Prepared
Effects read and decoded by EffectCache::prepare, for EffectCache::add.
Scene
The sound scene: up to 256 playing effects and 4,096 effects in the world, their emitters, and the volumes of the kinds of sound. Scene::update mixes them every frame.
Volumes
The volume of each kind of sound, from 0 to 100, as in the Audio options.

Traits§

Mixer
What the scene needs from the channel pool (implemented by crate::Device).