Disabling Auto Gain Conctrol with WebRTC App

﹥>﹥吖頭↗ 提交于 2019-11-28 10:21:57

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 (recent additions to the spec that rely on adapter.js here except in Firefox Nightly).

Firefox currently tends to 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 (again, use adapter.js to avoid vendor prefixes).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!