WebAudio / web-audio-api

The Web Audio API v1.0, developed by the W3C Audio WG
https://webaudio.github.io/web-audio-api/
Other
1.05k stars 166 forks source link

maxChannelCount vs sinkId #2528

Closed chrisguttandin closed 1 year ago

chrisguttandin commented 1 year ago

Describe the issue

Currently the setter of the channelCount property of the AudioDestinationNode is meant to fire an IndexSizeError if the "value is not within the valid range".

But now that it's possible to change the audio output device the valid range might change at any time. Let's imagine the currently used audio output device has 6 channels and all 6 of them are in use.

audioContext.destination.channelCount = 6;

But later on the audio output device gets changed and the newly selected device only supports 2 channels.

audioContext.setSinkId('id-of-a-device-with-two-channels');

I guess this should throw an IndexSizeError, too.

Where Is It

https://webaudio.github.io/web-audio-api/#AudioDestinationNode

Additional Information

I'm not sure if this case is already handled somewhere in the spec. Theoretically it was already possible before to change the audio output device without setSinkId() by changing the default audio output device on the OS level.

orottier commented 1 year ago

In similar vein: in the future we can choose a render quantum size optimized for the current sink (AudioContextRenderSizeCategory::hardware) which should remain constant for the lifetime of the BaseAudioContext. But what should happen when we change the sinkId?

guest271314 commented 1 year ago

Determining channelCount is tedious and currently must be done manually.

E.g., if you do not set channelCount explicitly in constraints passed to getUserMedia() the channelCount will be 1.

mdjp commented 1 year ago

After discussion, we will continue to use the downmixing mechanism in the API. A new issue will be raised to ensure that an event is triggered on device change.

padenot commented 1 year ago

After discussion, we will continue to use the downmixing mechanism in the API. A new issue will be raised to ensure that an event is triggered on device change.

This is https://github.com/WebAudio/web-audio-api/issues/2532.