Logo Mibo

AudioService Type

The raylib-backed IAudio: file-path sound/music registration, an 8-alias ring per sound, a single music channel, and the fade state machine driven by IAudio.Tick.

Register entries right after the host registers the service (the RaylibProgram.withBank builder does this for MVU programs) — sounds load into memory at that point, before user init runs.

Paths resolve against the game's asset base path when the program set one with withAssetsBasePath, the same rule as the asset service. File formats: WAV, OGG, MP3, FLAC, QOA (whatever the raylib build decodes).

Fades interpolate the music channel volume through the Core Fade.volume helper. A fade to (or below) zero stops the music when it completes. The volume a fade-in returns to is the last one passed to AudioService.SetMusicVolume (1.0 if never set). A newly started track cancels any running fade and starts at that same volume — a fade-out ends the track that was playing, it is not a sticky volume.

Constructors

Constructor Description

AudioService(baseAssetPath)

Full Usage: AudioService(baseAssetPath)

Parameters:
    baseAssetPath : string voption

Returns: AudioService
baseAssetPath : string voption
Returns: AudioService

Instance members

Instance member Description

this.Dispose

Full Usage: this.Dispose

Unloads every registered sound, alias, and music stream.

this.MusicVolume

Full Usage: this.MusicVolume

Returns: float32

The current music slider value — the volume a fade-in returns to.

Returns: float32

this.RegisterMusic

Full Usage: this.RegisterMusic

Parameters:
    key : string - The game-vocabulary key to start the track with (e.g. "overworld").
    path : string - File path (relative to the program's asset base path when one is set).

Registers a music track from a file path. Loading a key twice keeps the first registration. A file that fails to load is skipped (raylib logs a warning) — the key plays nothing.

key : string

The game-vocabulary key to start the track with (e.g. "overworld").

path : string

File path (relative to the program's asset base path when one is set).

this.RegisterSound

Full Usage: this.RegisterSound

Parameters:
    key : string - The game-vocabulary key to play the sound with (e.g. "jump").
    path : string - File path (relative to the program's asset base path when one is set).

Registers a sound effect from a file path. Loading a key twice keeps the first registration. A file that fails to load is skipped (raylib logs a warning) — its key plays nothing.

key : string

The game-vocabulary key to play the sound with (e.g. "jump").

path : string

File path (relative to the program's asset base path when one is set).

this.Tick

Full Usage: this.Tick

Parameters:
    dt : float32 - Elapsed seconds since the last frame.

Advances music streaming and fade interpolation by one frame. The host calls this every frame; calling it yourself double-steps the music.

dt : float32

Elapsed seconds since the last frame.

Type something to start searching.