10

is there a way to disable the WebRTC "auto gain control feature" by default, by applying some javascript code to the app files?

i am using simplewebrtc.

jib
  • 40,579
  • 17
  • 100
  • 158
jhon dano
  • 660
  • 6
  • 23

2 Answers2

20

You can turn off audio processing using constraints (use https fiddle for Chrome):

var constraints = {
  audio: {
    echoCancellation: false,
    noiseSuppression: false,
    autoGainControl: false,
  }
};

navigator.mediaDevices.getUserMedia(constraints)
  .then(stream => audio.srcObject = stream)
  .catch(e => log(e));

var log = msg => div.innerHTML += msg + "<br>";
<audio id="audio" controls autoplay></audio><br>
<div id="div"></div>
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>

Chrome apparently turns off all audio processing when echoCancellation: false is specified.

Firefox doesn't do that yet, so include autoGainControl: false and noiseSuppression: false as well for now.

Both Chrome and Firefox (64+) appear to default autoGainControl to true.

Older versions of Firefox would default autoGainControl to false and noiseSuppression to true, but like all device settings, defaults may vary from browser to browser, device to device or even the situation, so if you care about a setting, constrain it.

All three settings can also be controlled individually in Chrome and Firefox.

jib
  • 40,579
  • 17
  • 100
  • 158
  • Just for clarification: I tumbled over many posts, issues and blog entries saying the same. Can you explain why you would do this? I thought those constraints are better if set to true (no echoes, no big differences in volume...) – hogan Oct 20 '21 at 11:44
  • 1
    @hogan The browser defaults are tuned for speech in video conferences, so if that's what you're doing, leave them alone. But listening to music over that video conference likely sounds terrible. There are also use cases for microphone other than video conferencing, where echo cancellation is unnecessary, such as recording or audio mixing. – jib Oct 20 '21 at 20:02
  • understood, thank you! – hogan Oct 21 '21 at 07:10
1

There is now a google extension that can fix this.

https://chrome.google.com/webstore/detail/disable-automatic-gain-co/clpapnmmlmecieknddelobgikompchkk/related

Darwin
  • 4,686
  • 2
  • 30
  • 22