Logo Mibo

IAudio Type

The backend-neutral audio service. Every windowed host registers one under this interface before user init runs; resolve it with GameContext.getService<IAudio> ctx (the MVU Cmd helpers and the adaptive intent helpers do this for you and no-op when it is absent).

Sound effects overlap: each key owns a small pool of playback slots, so playing the same key several times per frame layers the copies. Music is a single channel — starting a track replaces the one playing.

Unknown keys are silent no-ops, so headless programs and test runs never need an audio device.

Example

 let audio = GameContext.getService<IAudio> ctx
 audio.Play "jump"
 audio.PlayMusic "overworld"        // loops
 audio.FadeMusic(0.0f, 1.5f)        // fade out over 1.5 s, then stop
val audio: obj

Instance members

Instance member Description

this.FadeMusic

Full Usage: this.FadeMusic

Parameters:
    targetVolume : float32 - The volume to reach (0.0 = fade out and stop).
    seconds : float32 - Fade duration in seconds; zero or less jumps straight to the target.

Modifiers: abstract

Fades the music volume to targetVolume over seconds. A fade to (or below) zero stops the music when it completes; a fade to a positive volume leaves it playing.

targetVolume : float32

The volume to reach (0.0 = fade out and stop).

seconds : float32

Fade duration in seconds; zero or less jumps straight to the target.

this.MusicPosition

Full Usage: this.MusicPosition

Returns: float32
Modifiers: abstract

The music playback position in seconds.

Returns: float32

this.MusicVolume

Full Usage: this.MusicVolume

Returns: float32 The music slider value, 0.0..1.0.
Modifiers: abstract

The music volume — the current value of the music slider, as set through IAudio.SetMusicVolume (1.0 if never set). This is the volume a fade with no explicit target returns to, so the MVU fadeMusicIn and adaptive fadeMusicIn helpers read it from here.

Returns: float32

The music slider value, 0.0..1.0.

this.PauseMusic

Full Usage: this.PauseMusic

Modifiers: abstract

Pauses the music at the current position.

this.Play

Full Usage: this.Play

Parameters:
    key : string - The game-vocabulary key the sound was registered under (e.g. "jump").
    voice : Voice - Volume, pan, and pitch for this playback only.

Modifiers: abstract

Plays the sound registered under key with per-play knobs.

key : string

The game-vocabulary key the sound was registered under (e.g. "jump").

voice : Voice

Volume, pan, and pitch for this playback only.

this.Play

Full Usage: this.Play

Parameters:
    key : string - The game-vocabulary key the sound was registered under (e.g. "jump").

Modifiers: abstract

Plays the sound registered under key with the default voice.

key : string

The game-vocabulary key the sound was registered under (e.g. "jump").

this.PlayMusic

Full Usage: this.PlayMusic

Parameters:
    key : string

Modifiers: abstract

Plays the music registered under key, looping — the background-music case. Replaces the track that is playing.

key : string

this.PlayMusicOnce

Full Usage: this.PlayMusicOnce

Parameters:
    key : string

Modifiers: abstract

Plays the music registered under key once through, then stops. Replaces the track that is playing.

key : string

this.ResumeMusic

Full Usage: this.ResumeMusic

Modifiers: abstract

Resumes the music from where it was paused.

this.SeekMusic

Full Usage: this.SeekMusic

Parameters:
    seconds : float32 - The position to jump to, counted from the track start.

Modifiers: abstract

Seeks the music to an absolute time in seconds.

seconds : float32

The position to jump to, counted from the track start.

this.SetMasterVolume

Full Usage: this.SetMasterVolume

Parameters:
    volume : float32 - Master volume (1.0 = full). Values outside 0.0..1.0 clamp.

Modifiers: abstract

Sets the master volume that scales the whole mix — every sound effect and the music channel — live, on sounds that are already playing too. Rule on both backends: master volume is the one knob above everything; per-backend engines apply it differently, the services make them behave the same. Music volume is set separately with IAudio.SetMusicVolume.

volume : float32

Master volume (1.0 = full). Values outside 0.0..1.0 clamp.

this.SetMusicVolume

Full Usage: this.SetMusicVolume

Parameters:
    volume : float32 - Music volume (1.0 = full, 0.0 = silent).

Modifiers: abstract

Sets the music volume live — the music slider. This is also the volume a later fade-in returns to.

volume : float32

Music volume (1.0 = full, 0.0 = silent).

this.StopAllSounds

Full Usage: this.StopAllSounds

Modifiers: abstract

Stops every playing sound effect. Music keeps playing.

this.StopMusic

Full Usage: this.StopMusic

Modifiers: abstract

Stops the music and resets it to its start.

this.Tick

Full Usage: this.Tick

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

Modifiers: abstract

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

dt : float32

Elapsed seconds since the last frame.

Type something to start searching.