最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Web Audio Api input from specific microphone - Stack Overflow

programmeradmin1浏览0评论

I'm using the Web Audio Api ( navigator.getUserMedia({audio: true}, function, function) ) for audio recording.

If the user has several microphone devices, can I select the desired recording device?

I've came across a problematic situation where a brand new Dell laptop (running Windows 8.1) has 2 microphone devices (on board and external) and the external device was set to default (set to default by the operation system).

As expected, when recording, the input es from the external microphone which means - silence - no actual input.

Can I work around this technologically and capture the audio from the on board device?

While searching I found this question which talks about detecting the sound card.

From the answer:

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.

Recording devices screenshot - .jpg (can't add the actual photo yet)

Would appreciate suggestions.

Thanks! Avi.

I'm using the Web Audio Api ( navigator.getUserMedia({audio: true}, function, function) ) for audio recording.

If the user has several microphone devices, can I select the desired recording device?

I've came across a problematic situation where a brand new Dell laptop (running Windows 8.1) has 2 microphone devices (on board and external) and the external device was set to default (set to default by the operation system).

As expected, when recording, the input es from the external microphone which means - silence - no actual input.

Can I work around this technologically and capture the audio from the on board device?

While searching I found this question which talks about detecting the sound card.

From the answer:

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.

Recording devices screenshot - https://i.sstatic/jUrCw.jpg (can't add the actual photo yet)

Would appreciate suggestions.

Thanks! Avi.

Share Improve this question edited May 23, 2017 at 10:30 CommunityBot 11 silver badge asked Jul 7, 2015 at 9:16 Avi AnkonaAvi Ankona 931 gold badge2 silver badges8 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

You want to use device enumeration and a deviceid constraint. As per @cwilso's answer, https://webaudiodemos.appspot./input/index.html is an example that works in Chrome. If you change the default microphone in the OS, Chrome should pick it up.

Firefox is adding deviceIds and constraints, but they haven't hit release yet. Currently on firefox the user can select any audio device for input if they don't select "Allow Always" when approving (if they do, then it will select the default device without asking the user). Note that Allow Always requires loading over https, and it's not the default action (unlike Chrome).

You can select any recording device you want with Web Audio API, look at https://jsfiddle/bomzj/beap6n2g/.

You can (select the input device) - take a look at https://webaudiodemos.appspot./input/index.html, which lets the user select the input. Note that you won't get access to the actual names unless you serve securely (https instead of http).

发布评论

评论列表(0)

  1. 暂无评论