Skip to content

Commit

Permalink
Fixed wrong channels and buggy disconnects in Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielku15 committed Aug 16, 2021
1 parent 63f47c2 commit 70eb7c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/platform/javascript/AlphaSynthAudioWorkletOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,13 @@ export class AlphaSynthAudioWorkletOutput extends AlphaSynthWebAudioOutputBase {
// create a script processor node which will replace the silence with the generated audio
ctx.audioWorklet.addModule(Environment.scriptFile!).then(
() => {
this._worklet = new AudioWorkletNode(ctx!, 'alphatab');
this._worklet = new AudioWorkletNode(ctx!, 'alphatab', {
numberOfOutputs: 1,
outputChannelCount: [2]
});
this._worklet.port.onmessage = this.handleMessage.bind(this);

this._source!.connect(this._worklet, 0, 0);
this._source!.connect(this._worklet);
this._source!.start(0);
this._worklet.connect(ctx!.destination);
},
Expand All @@ -178,7 +181,8 @@ export class AlphaSynthAudioWorkletOutput extends AlphaSynthWebAudioOutputBase {
public pause(): void {
super.pause();
if (this._worklet) {
this._worklet.disconnect(0);
this._worklet.port.onmessage = null;
this._worklet.disconnect();
}
this._worklet = null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/javascript/AlphaSynthWebAudioOutputBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export abstract class AlphaSynthWebAudioOutputBase implements ISynthOutput {
public pause(): void {
if (this._source) {
this._source.stop(0);
this._source.disconnect(0);
this._source.disconnect();
}
this._source = null;
}
Expand Down

0 comments on commit 70eb7c3

Please sign in to comment.