Fix channel reading for non-native playback
This patch fixes the playback issues in stereo file played in multichannel setup.
Now channel count is always passed as mediafile's STREAMINFO channel count. In the next steps upmixing and downmixing handled by browser side.
Merge request reports
Activity
Hi,
I think your MR will break the 5.1 samples played on stereo hardware. Unless the point 3.1 of the spec is not enforced https://webaudio.github.io/web-audio-api/#configuring-channels-with-audioworkletnodeoptions. If
maxChannelCount
is 2 I don't think you can setchannels
in the audioworkletnode(awn) to more than 2. In that case, ifaout_FormatNbChannels
is more thanmaxChannelCount
an exception will be thrown.To sumup, as we discussed with @alaric, we can fix the current issue in two ways:
- Use vlc to handle up/down-mixing:
We consider that the awn is an output node and we always set the
channels
variable to maxChannelCount. For downmixing, we change change fmt-> after initialization of the awn, in Start(). For upmixing, we use a filter so that the blocks we send to the awn have the desired number of channels.- Use webaudio's channelInterpretation feature:
We don't use the awn as an output node, which means we need to add one with the desired number of channels based on
maxChannelCount
. The awn node will have the file channel number, and the other node (GainNode, for example) will havemaxChannelCount
as the number of channels.Edited by Mehdi Sabwat