fix: kill in-flight SFX when navigating away from fight
Disconnect and recreate sfxGain in stopAllAudio() so oscillators and noise buffers stop immediately instead of playing to completion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
e92f483e66
commit
168e1e3a32
@@ -340,6 +340,14 @@ export function stopAllAudio() {
|
|||||||
stopMusic()
|
stopMusic()
|
||||||
if (typeof speechSynthesis !== 'undefined') speechSynthesis.cancel()
|
if (typeof speechSynthesis !== 'undefined') speechSynthesis.cancel()
|
||||||
_speechQueueDepth = 0
|
_speechQueueDepth = 0
|
||||||
|
// Disconnect sfxGain to instantly kill all in-flight oscillators/buffers,
|
||||||
|
// then reconnect so future sounds still work
|
||||||
|
if (sfxGain && ctx) {
|
||||||
|
sfxGain.disconnect()
|
||||||
|
sfxGain = ctx.createGain()
|
||||||
|
sfxGain.gain.value = masterMuted ? 0 : 0.25
|
||||||
|
sfxGain.connect(ctx.destination)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Public voice functions
|
// Public voice functions
|
||||||
|
|||||||
Reference in New Issue
Block a user