Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access all input channels of an audio interface using the WebAudio API?

I'm trying to access all the audio channels of an attached multi-input audio interface. I understand that the channels should be exposed by the MediaStreamAudioSourceNode node after it has been created with a MediaStream:

navigator.getUserMedia({ audio: true }, function(stream) {
    var input = audio.createMediaStreamSource(stream);
    console.log(input.channelCount);
});

The problem is that input.channelCount is always 2, no matter which device is chosen as the user media source. This is true of Chrome and FireFox.

The Media Capture and Streams spec states:

A single MediaStreamTrack can represent multi-channel content, such as stereo or 5.1 audio or stereoscopic video, where the channels have a well defined relationship to each other. Information about channels might be exposed through other APIs, such as [WEBAUDIO], but this specification provides no direct access to channels.

(http://w3c.github.io/mediacapture-main/getusermedia.html#introduction)

That suggests there is no way of influencing the number of channels through getUserMedia calls (unless there is some special constraint parameter that I am missing).

The WebAudio spec for MediaStreamAudioSourceNode states:

The first AudioMediaStreamTrack from the MediaStream will be used as a source of audio. [...] The number of channels of the output corresponds to the number of channels of the AudioMediaStreamTrack.

(http://webaudio.github.io/web-audio-api/#MediaStreamAudioSourceNode)

When I inspect the stream created by getUserMedia, it has one single track. As far as I can see, it is impossible to inspect that track's number of channels. So it seems that either:

  1. getUserMedia is only streaming the first two channels of audio from an attached device to a single MediaStreamTrack.

  2. The MediaStreamAudioSourceNode is ignoring any more than the first two channels found in a MediaStreamTrack.

Does anyone have more information on this problem? Am I missing something? Is it not implemented properly yet? How can we go about getting it fixed?

like image 490
stephband Avatar asked Feb 09 '15 16:02

stephband


1 Answers

Chrome simply doesn't support this yet. Known issue. Hongchan's been looking at it.

like image 69
cwilso Avatar answered Sep 27 '22 20:09

cwilso