How can I disable automatic gain control (AGC) in WebRTC web-apps such as Google Hangouts or OpenTokRTC

Charl Botha picture Charl Botha · Oct 21, 2014 · Viewed 7.5k times · Source

In pre-WebRTC googletalkplugin days, one could disable AGC (automatic gain control for the microphone) by adding audio-flags: 1 to the config file. However, since Google Hangouts now use WebRTC, it often happens that while I'm chatting with someone, my microphone level shoots all the way down so that I'm more or less silent on the other side. I've also had correspondents whose mic volume was boosted all the way up, repeatedly.

I've reproduced this behaviour on http://opentokrtc.com/ which also uses WebRTC. By making loud popping sounds into my microphone, I can get the level to go all the way down in a few steps. I can do this both on Chrome 38 and FireFox 34 beta.

However, when I use a local application, such as Audacity, on my Ubuntu 14.04.1 machine, I am not able to affect the microphone level by making loud popping noises. In other words, it really looks like WebRTC is the culprit here.

It seems that on Chrome's implementation, one can configure WebRTC AGC by passing the googAutoGainControl to the getUserMedia() call. On FireFox I have not been able to find the equivalent.

My question is: As a WebRTC end-user, how can I configure my browser (Chrome or FireFox) to disable AGC, as AGC does not work correctly on my setup?

Answer

Alexander Salas Bastidas picture Alexander Salas Bastidas · Apr 7, 2015

The googAutoGainControl as MediaTrackConstraints is specific to Chrome (WebKit).

The WebRTC Working Group Charter still writing the standard and they will finish the next 30 June 2015.

Firefox not support right now.

Note: Use AGC is not recommended that you specify any browser-specific constraint as mandatory, as your call will fail in a browser that does not support the constraint. Instead, specify your constraints as optional. Your browser will do its best to satisfy as many optional constraints as possible.

BTW you can play with the GainNode interface in Firefox: https://developer.mozilla.org/en-US/docs/Web/API/GainNode

Example to disable the googAutoGainControl:

  var webrtc = new SimpleWebRTC({
    localVideoEl: 'localVideo',
    remoteVideosEl: '',
    autoRequestMedia: true,
    //detectSpeakingEvents: true,
    adjustPeerVolume: false,
    peerVolumeWhenSpeaking: 1,  
    media: {
      audio: {
        optional: [
          //{sourceId: audio_source},
          {googAutoGainControl: false}, 
          {googAutoGainControl2: false}, 
          {googEchoCancellation: false},
          {googEchoCancellation2: false},
          {googNoiseSuppression: false},
          {googNoiseSuppression2: false},
          {googHighpassFilter: false},
          {googTypingNoiseDetection: false},
          {googAudioMirroring: false}
        ]
     },
     video: {
        optional: [
          //{sourceId: video_source}
        ]
      }
    }
    //autoAdjustMic: false        
  });

The end-user cannot disable in the browser this functionality right now. The advanced user can edit preferences in the about:config in Firefox but in Chrome does not exist.