From 2b7257b2e0a121713e7fdf069eed02680d8279f4 Mon Sep 17 00:00:00 2001 From: frialey63 Date: Thu, 13 Jul 2023 10:27:10 +0100 Subject: [PATCH 1/3] set the channel interpretation on the AudioContext to speakers so that mono wavs are output on both channels in a conventional stereo setup --- .../frontend/src/audio-stream-player.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/resources/META-INF/resources/frontend/src/audio-stream-player.js b/src/main/resources/META-INF/resources/frontend/src/audio-stream-player.js index 9abcc83..b30741b 100644 --- a/src/main/resources/META-INF/resources/frontend/src/audio-stream-player.js +++ b/src/main/resources/META-INF/resources/frontend/src/audio-stream-player.js @@ -41,6 +41,17 @@ export const AudioStreamPlayer = (() => { this._multiChannelGainNode = new MultiChannelGainNode(this._gainNode); + // Set channel interpretation to speakers so that a mono audio source is output on two channels + console.log('setting channel interpretation to speakers'); + + const oscillator = this._context.createOscillator(); + const gainNode = this._gainNode; + + oscillator.connect(gainNode); + gainNode.connect(this._context.destination); + + oscillator.channelInterpretation = "speakers"; + // Could use StereoPannerNode instead, but it is missing in Safari :-( this._pannerNode = this._context.createPanner(); this._pannerNode.panningModel = 'equalpower'; @@ -229,6 +240,11 @@ export const AudioStreamPlayer = (() => { audio => { const currentChunkTimestamp = Math.max(0, this._position - this._chunkOverlapTime); player.buffer = audio; + + //console.log('switching to 2-channel mono: ', audio.length); + //audio.output.L = input.M; + //audio.output.R = input.M; + if (this._tryResume && timestamp === currentChunkTimestamp) { this._tryResume(); } From bed94908398908101b4013c3ded4596c41de1cca Mon Sep 17 00:00:00 2001 From: frialey63 Date: Thu, 13 Jul 2023 10:33:13 +0100 Subject: [PATCH 2/3] fix formatting by removing the tabs --- .../resources/frontend/src/audio-stream-player.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/META-INF/resources/frontend/src/audio-stream-player.js b/src/main/resources/META-INF/resources/frontend/src/audio-stream-player.js index b30741b..7c31288 100644 --- a/src/main/resources/META-INF/resources/frontend/src/audio-stream-player.js +++ b/src/main/resources/META-INF/resources/frontend/src/audio-stream-player.js @@ -45,12 +45,12 @@ export const AudioStreamPlayer = (() => { console.log('setting channel interpretation to speakers'); const oscillator = this._context.createOscillator(); - const gainNode = this._gainNode; + const gainNode = this._gainNode; - oscillator.connect(gainNode); - gainNode.connect(this._context.destination); + oscillator.connect(gainNode); + gainNode.connect(this._context.destination); - oscillator.channelInterpretation = "speakers"; + oscillator.channelInterpretation = "speakers"; // Could use StereoPannerNode instead, but it is missing in Safari :-( this._pannerNode = this._context.createPanner(); From 1260c5926ff4756ba97dc9129189946662c748b1 Mon Sep 17 00:00:00 2001 From: frialey63 Date: Thu, 13 Jul 2023 10:36:26 +0100 Subject: [PATCH 3/3] more formatting on the comment line --- .../META-INF/resources/frontend/src/audio-stream-player.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/META-INF/resources/frontend/src/audio-stream-player.js b/src/main/resources/META-INF/resources/frontend/src/audio-stream-player.js index 7c31288..f3c3779 100644 --- a/src/main/resources/META-INF/resources/frontend/src/audio-stream-player.js +++ b/src/main/resources/META-INF/resources/frontend/src/audio-stream-player.js @@ -41,7 +41,7 @@ export const AudioStreamPlayer = (() => { this._multiChannelGainNode = new MultiChannelGainNode(this._gainNode); - // Set channel interpretation to speakers so that a mono audio source is output on two channels + // Set channel interpretation to speakers so that a mono audio source is output on two channels console.log('setting channel interpretation to speakers'); const oscillator = this._context.createOscillator();