Skip to content

Commit

Permalink
Take @8bitkick's advice
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgodbolt committed Jan 1, 2025
1 parent 388de05 commit 743d0b4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/web/audio-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ export class AudioHandler {
async _setup(audioFilterFreq, audioFilterQ) {
await this.audioContext.audioWorklet.addModule(rendererUrl);
if (audioFilterFreq !== 0) {
this.soundChip.filterNode = this.audioContext.createBiquadFilter();
this.soundChip.filterNode.type = "lowpass";
this.soundChip.filterNode.frequency.value = audioFilterFreq;
this.soundChip.filterNode.Q.value = audioFilterQ;
this._audioDestination = this.soundChip.filterNode;
this.soundChip.filterNode.connect(this.audioContext.destination);
const filterNode = this.audioContext.createBiquadFilter();
filterNode.type = "lowpass";
filterNode.frequency.value = audioFilterFreq;
filterNode.Q.value = audioFilterQ;
this._audioDestination = filterNode;
filterNode.connect(this.audioContext.destination);
} else {
this._audioDestination = this.audioContext.destination;
}
Expand All @@ -111,8 +111,7 @@ export class AudioHandler {
if (this._jsAudioNode) this._jsAudioNode.port.postMessage({ time: Date.now(), buffer }, [buffer.buffer]);
}

// Recent browsers, particularly Safari and Chrome, require a user
// interaction in order to enable sound playback.
// Recent browsers, particularly Safari and Chrome, require a user interaction in order to enable sound playback.
async tryResume() {
if (this.audioContext) await this.audioContext.resume();
if (this.audioContextM5000) await this.audioContextM5000.resume();
Expand Down

0 comments on commit 743d0b4

Please sign in to comment.