Skip to content

@modoki/engine / index / crossfadeAudio

Function: crossfadeAudio()

crossfadeAudio(outgoing, incoming, targetVolume?, durationSec?): void

Crossfade two playing handles: fade outgoing to 0 and incoming up to targetVolume over durationSec. The caller owns lifetime — outgoing keeps playing silently until the caller stop()s it (looping music never self-ends), so stop it after the fade. Pass an incoming started at volume 0.

Parameters

outgoing

AudioHandle | null | undefined

incoming

AudioHandle | null | undefined

targetVolume?

number = 1

durationSec?

number = 0.5

Returns

void

Built with Modoki.