API Reference › Audio
namespace

Audio

Sound effects and music. A sound is loaded once with Audio.load into a handle; Audio.play fires it one-shot and Audio.play_music loops it on a single music channel. Playback is out-of-band — the audio device is real-time, not part of the deterministic simulation — but every trigger here is an ordinary frame-driven call, so a recorded run replays the same sounds at the same frames. Headless builds carry the whole API as no-ops (no audio device needed), so the same game code runs under the test harness.

Audio.load(path) -> intLoad a sound file into a handle.Audio.play(id) -> voidFire a one-shot sound.Audio.play_at(id, gain, pitch, pan) -> voidFire a one-shot with its own gain, pitch and stereo position.Audio.play_sound(id) -> voidFire a one-shot sound (alias of play).Audio.play_music(id) -> voidLoop a sound as background music.Audio.stop(id) -> voidStop one sound.Audio.stop_music() -> voidStop the music channel.Audio.stop_all() -> voidStop every sound.Audio.volume(v) -> voidSet the master volume.Audio.pitch(v) -> voidSet the playback rate / pitch.Audio.is_playing(id) -> boolIs this sound playing?Audio.define(name: s, path: p) -> intLoad a sound into the bank under a name.Audio.named(name: s) -> intThe handle registered under a name, or 0.
← All symbols