Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web audio API : Mic stream to speaker volume drop?

I am using the Web audio API to stream my mic input into the speakers, so I can hear myself talk through them:

var aCtx = new AudioContext();
navigator.mediaDevices.getUserMedia({audio: true}).then(function (stream) {
     var microphone = aCtx.createMediaStreamSource(stream);
     microphone.connect(aCtx.destination);
})

It works fine, but whenever I keep a steady long voice input, it seems like the output gain drops after a couple of seconds.

I have followed cwilso's advice and added the echo cancellation constraint. But the results are still the same.

Here's a Fiddle: https://jsfiddle.net/hcrgL9eg/

Help would be appreciated.

like image 274
Niko Avatar asked Jan 26 '17 21:01

Niko


1 Answers

Yeah, you're hitting "auto gain control". There are a bunch of features on audio input that are on by default (echo cancellation, AGC, noise reduction). Take a look at Disabling Auto Gain Conctrol with WebRTC App; it's the same solution.

like image 56
cwilso Avatar answered Oct 04 '22 21:10

cwilso