diff --git a/shared/js/codec/BasicCodec.ts b/shared/js/codec/BasicCodec.ts index e6b806c9..f16187d9 100644 --- a/shared/js/codec/BasicCodec.ts +++ b/shared/js/codec/BasicCodec.ts @@ -49,8 +49,8 @@ abstract class BasicCodec implements Codec { encodeSamples(cache: CodecClientCache, pcm: AudioBuffer) { - this._encodeResampler.resample(pcm).then(buffer => this.encodeSamples0(cache, buffer)) - .catch(error => console.error("Could not resample PCM data for codec. Error:" + error)); + this._encodeResampler.resample(pcm).catch(error => console.error("Could not resample PCM data for codec. Error:" + error)) + .then(buffer => this.encodeSamples0(cache, buffer as any)).catch(error => console.error("Could not encode PCM data for codec. Error:" + error)) } diff --git a/shared/js/codec/Codec.ts b/shared/js/codec/Codec.ts index d5ed395f..e4502a93 100644 --- a/shared/js/codec/Codec.ts +++ b/shared/js/codec/Codec.ts @@ -23,7 +23,8 @@ class BufferChunk { copyRangeTo(target: AudioBuffer, maxLength: number, offset: number) { let copy = Math.min(this.buffer.length - this.index, maxLength); - for(let channel = 0; channel < this.buffer.numberOfChannels; channel++) { + //TODO may warning if channel counts are not queal? + for(let channel = 0; channel < Math.min(target.numberOfChannels, this.buffer.numberOfChannels); channel++) { target.getChannelData(channel).set( this.buffer.getChannelData(channel).subarray(this.index, this.index + copy), offset diff --git a/shared/js/voice/VoiceHandler.ts b/shared/js/voice/VoiceHandler.ts index a799ea7f..b3ba6373 100644 --- a/shared/js/voice/VoiceHandler.ts +++ b/shared/js/voice/VoiceHandler.ts @@ -124,7 +124,7 @@ class VoiceConnection { dataChannel: RTCDataChannel; voiceRecorder: VoiceRecorder; - private _type: VoiceConnectionType = VoiceConnectionType.JS_ENCODE; + private _type: VoiceConnectionType = VoiceConnectionType.NATIVE_ENCODE; local_audio_stream: any; diff --git a/shared/js/voice/VoiceRecorder.ts b/shared/js/voice/VoiceRecorder.ts index 47619dfb..e9e53234 100644 --- a/shared/js/voice/VoiceRecorder.ts +++ b/shared/js/voice/VoiceRecorder.ts @@ -212,7 +212,9 @@ class VoiceRecorder { getUserMediaFunction()({ audio: { deviceId: device, - groupId: groupId + groupId: groupId, + echoCancellation: true, + echoCancellationType: 'browser' } }, this.on_microphone.bind(this), error => { createErrorModal("Could not resolve microphone!", "Could not resolve microphone!
Message: " + error).open();