Description
The Problem
The ChannelSplitterNode uses index 0 (SPEAKER_FRONT_LEFT) for mono audio. This causes the audio to play on the left speaker only. To ensure that mono audio plays on both speakers, the audio should be sent to the channel index corresponding to SPEAKER_FRONT_CENTER instead.
Adjusting this behavior programmatically is difficult because the API doesn't provide information on the number of channels the audio source provides. The spatial audio format must be known to programmatically connect splitter's channel 0 to merger's channel 2 for mono audio only while keeping the usual order for other formats.
Potential Solutions
- Implement a method to access information about the current set of mappings being used by the splitter
- Implement a node that upmixes/downmixes channels based on user-supplied conditions.
Workaround
Using the ability of the Panner
and StereoPanner
nodes to force stereo output regardless of the input, one can construct a network to achieve the following:
- If the audio source is mono, upmix to output mono audio on both the Left and Right channels.
- If the audio source is stereo, output stereo audio to both the Left and Right channels.
- If the audio source contains more than 2 channels, additional channels are passed through unaltered.
The resulting output can then be processed using ChannelSplitterNodes with proper behavior for both mono and stereo audio.
Limitations
As the Panner nodes have a maximum of 2 channels, this technique will not work for fixing audio issues caused by the differences between Quad
and 5.1
formats.