来自特定麦克风的网络音频 Api 输入

Web Audio Api input from specific microphone

我正在使用网络音频 Api ( navigator.getUserMedia({audio: true}, function, function) ) 进行录音。

如果用户有多个麦克风设备,我可以select想要的录音设备吗?

我遇到了一个有问题的情况,一台全新的戴尔笔记本电脑 (运行 Windows 8.1) 有 2 个麦克风设备(板载和外接)并且外接设备设置为默认(由操作系统设置为默认值)。

正如预期的那样,在录音时,输入来自外部麦克风,这意味着 - 静音 - 没有实际输入。

我可以在技术上解决这个问题并从机载设备捕获音频吗?

在搜索时我发现 this question 是关于检测声卡的。

来自回答:

You have no control over the latency. You have no way of detecting the actual sound device. All you can determine is if the browser gives you access to the audio channels, and how many of them. I've also found that regardless of what is on the other side, Chrome will only open up a stereo channel. (It will also treat mono devices as stereo, copying the first channel to both L and R channels.) Firefox has similar issues.

录制设备截图 - http://i.stack.imgur.com/jUrCw.jpg(还不能添加实际照片)

非常感谢您的建议。

谢谢! 阿维。

您可以(select 输入设备)- 查看 https://webaudiodemos.appspot.com/input/index.html,它可以让用户 select 输入。请注意,除非您安全地提供服务(https 而不是 http),否则您将无法访问实际名称。

您想使用设备枚举和 deviceid 约束。根据@cwilso 的回答,https://webaudiodemos.appspot.com/input/index.html 是一个适用于 Chrome 的示例。如果你在OS中更改默认麦克风,Chrome应该选择它。

Firefox 正在添加 deviceIds 和约束,但它们尚未发布。目前在 Firefox 上,用户 可以 select 任何音频设备进行输入,如果他们不 select "Allow Always" 批准时(如果他们这样做,那么它将 select 默认设备而不询问用户)。请注意 Allow Always 需要通过 https 加载,这不是默认操作(与 Chrome 不同)。

您可以 select 使用 Web Audio API 任何您想要的录音设备,请查看 https://jsfiddle.net/bomzj/beap6n2g/