Skip to main content

Module audio

Module audio 

Source
Expand description

Sound: the AudioSource component and the AudioBus that scripts talk to.

The engine itself plays nothing. Scripts and components only queue requests on the scene’s bus; a shell (the editor or the player) hands them to the kvas_audio backend once per frame. That keeps the simulation deterministic and testable without a sound card.

use kvas_engine::audio::AudioBus;
let mut bus = AudioBus::default();
let id = bus.play("sounds/click.wav", 0.8);
bus.stop(id);
assert_eq!(bus.drain().len(), 2);

Structs§

AudioBus
Pending audio requests and the master volume. Lives in the scene, is never saved.
AudioSource
A sound attached to an object: ambience, a radio, a machine hum.
SoundId
Handle of a sound started through the bus; use it to stop or adjust that sound later.

Enums§

AudioCmd
One queued request for the audio backend.

Functions§

cone_gain
Gain of a directional source: full inside the inner 60 % of the cone, fading to 10 % at its edge and beyond. forward is where the source points, to_listener the direction from the source to the listener.
distance_gain
Gain for a 3D sound: 1 inside min, falling linearly to 0 at max.
stereo_pan
Stereo position (-1 left .. 1 right) of a source seen from a listener.