Logo Mibo

AudioSurface Type

The audio helpers bound to one adaptive context, reachable as ctx.Audio on both AdaptiveFrameContext (Init) and AdaptiveContext (Update): play sound effects with per-play knobs, drive the single music channel (play, pause, seek, fades), and set volumes.

The sounds and tracks are registered before init runs — the hosts register the audio service unconditionally, and the backend program builders (AdaptiveRaylibProgram.withBank / AdaptiveMonoGameProgram.withBank) load the bank. Playing an unregistered key is a silent no-op, as is every helper when no audio service is registered (headless runs).

Each helper posts one unit -> unit closure, like every intent: posted from Update the work runs at the post drain (after the step's Update, before the frame is forced); posted from Init it runs at the startup drain, before the first frame is forced. The audio service resolves from the bound context before the closure is posted.

There are no mix groups: a sound-effect "bus" is model state the game multiplies into the voice at the play site, and music is a single channel with one live knob (setMusicVolume).

Example

 let update ctx state msg =
   match msg with
   | Jump ->
       ctx.Audio.play("jump")
       { state with Vy = jumpSpeed }
val update: ctx: 'a -> state: 'b -> msg: 'c -> 'b
val ctx: 'a
val state: 'b
val msg: 'c
val Jump: 'c

Instance members

Instance member Description

this.fadeMusicIn seconds

Full Usage: this.fadeMusicIn seconds

Parameters:
    seconds : float32 - Fade duration in seconds.

Modifiers: inline

Fades the music in over seconds, toward the current music slider value — the last volume passed to setMusicVolume (1.0 if never set), read from the service at post time.

seconds : float32

Fade duration in seconds.

this.fadeMusicOut seconds

Full Usage: this.fadeMusicOut seconds

Parameters:
    seconds : float32 - Fade duration in seconds.

Modifiers: inline

Fades the music out over seconds; the music stops when the fade completes.

seconds : float32

Fade duration in seconds.

this.pauseMusic ()

Full Usage: this.pauseMusic ()

Modifiers: inline

Pauses the music at the current position.

this.play key

Full Usage: this.play key

Parameters:
    key : string - The key the sound was registered under in the bank.

Modifiers: inline

Plays the sound registered under key with the default voice.

key : string

The key the sound was registered under in the bank.

this.playMusic key

Full Usage: this.playMusic key

Parameters:
    key : string - The key the track was registered under in the bank.

Modifiers: inline

Starts the music registered under key as the background track, looping. Replaces the track that is playing.

key : string

The key the track was registered under in the bank.

this.playMusicOnce key

Full Usage: this.playMusicOnce key

Parameters:
    key : string - The key the track was registered under in the bank.

Modifiers: inline

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

key : string

The key the track was registered under in the bank.

this.playWith (key, voice)

Full Usage: this.playWith (key, voice)

Parameters:
    key : string - The key the sound was registered under in the bank.
    voice : Voice - Volume, pan, and pitch for this playback (start from Voice.center and update fields).

Modifiers: inline

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

key : string

The key the sound was registered under in the bank.

voice : Voice

Volume, pan, and pitch for this playback (start from Voice.center and update fields).

this.resumeMusic ()

Full Usage: this.resumeMusic ()

Modifiers: inline

Resumes the music from where it was paused.

this.seekMusic seconds

Full Usage: this.seekMusic seconds

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

Modifiers: inline

Seeks the music to an absolute time in seconds.

seconds : float32

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

this.setMasterVolume volume

Full Usage: this.setMasterVolume volume

Parameters:
    volume : float32 - Master volume (1.0 = full).

Modifiers: inline

Sets the master volume that scales the whole mix — every sound effect and the music channel, live (see IAudio.SetMasterVolume).

volume : float32

Master volume (1.0 = full).

this.setMusicVolume volume

Full Usage: this.setMusicVolume volume

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

Modifiers: inline

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

volume : float32

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

this.stopAll ()

Full Usage: this.stopAll ()

Modifiers: inline

Stops every playing sound effect. Music keeps playing.

this.stopMusic ()

Full Usage: this.stopMusic ()

Modifiers: inline

Stops the music and resets it to its start.

Type something to start searching.