简体   繁体   English

网络音频API:麦克风流到扬声器音量下降?

[英]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: 我正在使用Web音频API将我的麦克风输入流式传输到扬声器中,因此我可以听到自己通过它们进行通话:

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. 我遵循了cwilso的建议并添加了回声消除约束。 But the results are still the same. 但结果仍然相同。

Here's a Fiddle: https://jsfiddle.net/hcrgL9eg/ 这是一个小提琴: https//jsfiddle.net/hcrgL9eg/

Help would be appreciated. 帮助将不胜感激。

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). 音频输入上有许多功能默认打开(回声消除,AGC,降噪)。 Take a look at Disabling Auto Gain Conctrol with WebRTC App ; 看看使用WebRTC App禁用自动增益控制 ; it's the same solution. 这是同样的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM