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 }
Instance members
| Instance member |
Description
|
Full Usage:
this.fadeMusicIn seconds
Parameters:
float32
-
Fade duration in seconds.
Modifiers: inline |
Fades the music in over seconds, toward the current music slider value — the last volume passed to
|
Full Usage:
this.fadeMusicOut seconds
Parameters:
float32
-
Fade duration in seconds.
Modifiers: inline |
Fades the music out over seconds; the music stops when the fade completes.
|
Full Usage:
this.pauseMusic ()
Modifiers: inline |
Pauses the music at the current position. |
Full Usage:
this.play key
Parameters:
string
-
The key the sound was registered under in the bank.
Modifiers: inline |
Plays the sound registered under key with the default voice.
|
Full Usage:
this.playMusic key
Parameters:
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.
|
Full Usage:
this.playMusicOnce key
Parameters:
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.
|
Full Usage:
this.playWith (key, voice)
Parameters:
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.
|
Full Usage:
this.resumeMusic ()
Modifiers: inline |
Resumes the music from where it was paused. |
Full Usage:
this.seekMusic seconds
Parameters:
float32
-
The position to jump to, counted from the track start.
Modifiers: inline |
Seeks the music to an absolute time in seconds.
|
Full Usage:
this.setMasterVolume volume
Parameters:
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).
|
Full Usage:
this.setMusicVolume volume
Parameters:
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.
|
Full Usage:
this.stopAll ()
Modifiers: inline |
Stops every playing sound effect. Music keeps playing. |
Full Usage:
this.stopMusic ()
Modifiers: inline |
Stops the music and resets it to its start. |
Mibo