How to echo cancellation? / Noise management in WebRTC?
HOME © Muaz Khan . @WebRTCWeb . Github . Latest issues . What's New?
This tutorial is out-dated (written in 2013). Please check this tutorial instead: https://codelabs.developers.google.com/codelabs/webrtc-web/#0
Useful Links!
Echo Scenarios:
- 44.1 kHz and non-44.1 kHz sample rate mismatches cause echo
- The "ambient noise reduction" which can be enabled on the built-in mic on Mac appears to cause a very small amount of echo
Solutions:
- Ensure both capture and render devices are set to either 44.1 or 48 kHz. You can do this through the "Audio MIDI Setup" application
- Disable "ambient noise reduction"
High volume can produce sound noise on some audio devices. The value may not be significant if audio device volume is controlled externally.
HTMLAudioElement.volume = 0.9; HTMLAudioElement.play();
The GainNode
is a simple element that lets us control the volume of the audio that’s coming into to it.
var context = new webkitAudioContext(), var sineWave = context.createOscillator(); // Declare gain node var gainNode = context.createGainNode(); // Connect sine wave to gain node sineWave.connect(gainNode); // Connect gain node to speakers gainNode.connect(context.destination); // Play sine wave sineWave.noteOn(0); gainNode.gain.value = 0.9;
Try demo locally to control volume using GainNode.
Suggestions
- If you're newcomer, newbie or beginner; you're suggested to try RTCMultiConnection.js or DataChannel.js libraries.