Re: Should we add a set Channel number API for Web Audio spec?

On Wed, Mar 14, 2012 at 12:38 AM, Liu, Raymond <raymond.liu@intel.com>wrote:

> Hi
>
>        I am working on adding multi-channel support for webaudio. When I
> come across the destination node, I realized that it is not easy for the
> audio destination node to choose the right channel number automatically.
>
>        1. you can hardly figure out the hardware support for channels
> numbers. On Linux, you can tweak the alsa config file to fake some channels
> support either for downmix or upmix.( maybe I am wrong on this? Please
> correct me) And even if you can figure out the real channel support of the
> hardware soundcard. Still have the issue 2:
>
>        2. not like <audio> tag, webaudio support up/down mix, take 5.1
> sound card for example, if you can find out the hardware capability of the
> sound card and automatically set it to 5.1 channels. Then since most of the
> source format is stereo, you will facing the issue that you need to upmix
> it to 5.1 inside webaudio, but you don't actually need to, since alsa can
> handle it, if the user really want to upmix 2.0 to 5.1. Then If alsa told
> you it support 5.1 but actually it doing it by downmix 5.1 to stereo, you
> are doing 2.0 ---- ( by webaudio) ---> 5.1 ---- (by Alsa) ---> 2.0, too
> bad...
>
>        3. setting the channels number on the fly according to source?
> Seems rather difficult if not impossible ( at least for alsa when a stream
> is already started. You can't do that.)
>
>        So, I am wondering, should we add a interface like
> context.setChannels? if the hardware don't support the channel layout,
> return the revised value. And the application probably know better on what
> kind of audio source they want to play.
>
>        And also a lot of webaudio node might benefit from knowing the
> target channels number, so that they can run more efficiently.
>
>        Any Ideas? Thanks.
>
> Best Regards,
> Raymond Liu
>

Hi Raymond, I'm also investigating the low-level details of getting/setting
the number of input and output channels for the default audio hardware
device (on Mac OS X for now) so I'm also interested in this.

One possibility is to have the API on the AudioDestinationNode
(context.destination).  This seems to make more sense to me since it's
really the destination we're working with.  It already has an attribute
.numberOfChannels.  It's currently read-only, but that could be relaxed.
 We also need a way to find out the full/maximum number of channels of the
device.  For example, if the device is capable of outputting 8 channels,
then perhaps we could have a .maxNumberOfChannels read-only attribute.
 Then .numberOfChannels would normally default to stereo, but could be
increased up to .maxNumberOfChannels.

I haven't really fully thought through all of the ramifications of this,
but it might be a good solution.

Cheers,
Chris

Received on Wednesday, 14 March 2012 19:30:54 UTC