How to disable Web-Audio analyzer filtering high frequencies

↘锁芯ラ 提交于 2019-12-04 13:12:11

@cwilso has it, the input is filtered by default, you need to pass a properly formed constraints object to getUserMedia. The format is a little fiddly but that's kind of unavoidable considering it's remit. The spec is not fully implemented by everyone yet either and each browser has it's own set of prefixed undocumented pre-processors. This is what I've been using to get the rawest audio available (Mid October 2016). This list is probably not complete either - I have only looked at FF and Ch so far. Anyone got any others?

let constraints = {
  audio: {
    optional: [
      {echoCancellation: false},
      {mozAutoGainControl: false},
      {mozNoiseSuppression: false},
      {googEchoCancellation: false},
      {googAutoGainControl: false},
      {googNoiseSuppression: false},
      {googHighpassFilter: false}
    ]
  }
};

let mediaInput = navigator.mediaDevices.getUserMedia( constraints );

It sounds like you're using audio (e.g. microphone) input? If so, make sure you're turning off echo cancellation - pass a constraint object to getUserMedia with echo cancellation set to false, a la https://github.com/cwilso/Audio-Input-Effects/blob/master/js/effects.js#L52-L57 and https://github.com/cwilso/Audio-Input-Effects/blob/master/js/effects.js#L160-L163. Otherwise, built-in processing is going to strip some things, including high frequencies.

2018 update: Chrome no longer needs the goog prefix, and highpassfilter is gone (I verified this with a soundcard that supports DC inputs):

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

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