Added possible echo cancellation and fixed encoder bug
This commit is contained in:
parent
f39e0c9f3b
commit
09ae0503b6
4 changed files with 8 additions and 5 deletions
|
@ -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))
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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!<br>Message: " + error).open();
|
||||
|
|
Loading…
Add table
Reference in a new issue