From d29862bb3bcf2ad3dbd50a43517a514f0524278f Mon Sep 17 00:00:00 2001 From: Danielku15 Date: Sun, 5 Jul 2026 14:55:38 +0200 Subject: [PATCH] fix(player): only buffer output events received between play and worklet creation --- .../platform/javascript/AlphaSynthAudioWorkletOutput.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/alphatab/src/platform/javascript/AlphaSynthAudioWorkletOutput.ts b/packages/alphatab/src/platform/javascript/AlphaSynthAudioWorkletOutput.ts index 204aef546..0198c896a 100644 --- a/packages/alphatab/src/platform/javascript/AlphaSynthAudioWorkletOutput.ts +++ b/packages/alphatab/src/platform/javascript/AlphaSynthAudioWorkletOutput.ts @@ -220,6 +220,13 @@ export class AlphaSynthAudioWorkletOutput extends AlphaSynthWebAudioOutputBase { public override play(): void { super.play(); const ctx = this.context!; + + // clear any pending events buffered from previous playback rounds + // we just want the events which come in after the play call until the worklet is created + if (this._pendingEvents) { + this._pendingEvents = undefined; + } + // create a script processor node which will replace the silence with the generated audio BrowserUiFacade.createAlphaSynthAudioWorklet(ctx, this._settings).then( () => {