XAudio2 Default Channel Mapping
An XAudio2 client has full control of the mapping from the channels of a voice to the channels of each of its destination voicesIt controls the mapping through the use of the IXAudio2Voice::SetOutputMatrix method. In some circumstances, however, XAudio2 simplifies this task by setting up a default send matrix automatically. It does this by using the channel mask, if any, associated with a voice's audio channels. A channel mask is a combination of SPEAKER_xxx bit masks as defined in X3DAudio.h and elsewhere. XAudio2 requires channel masks to be 0 or have the same number of bits set as the number of channels.
The following table shows the channel mask requirements and defaults for the formats supported by XAudio2.
|Format||Channel Mask Requirement||Default Mask||Corresponding Structure Member|
|PCM||File might contain a channel mask||Channel mask is 0, or absent||WAVEFORMATEXTENSIBLE.dwChannelMask or none (WAVEFORMATEX)|
|ADPCM||File does not contain a channel mask||Default Channel Mask is always used||None (ADPCMWAVEFORMAT)|
For submix and mastering voices, and for source voices without a channel mask or a channel mask of 0, XAudio2 assumes default speaker positions according to the following table.
|Channels||Implicit Channel Positions|
|1||Always maps to FrontLeft and FrontRight at full scale in both speakers (special case for mono sounds)|
|2||FrontLeft, FrontRight (basic stereo configuration)|
|3||FrontLeft, FrontRight, LowFrequency (2.1 configuration)|
|4||FrontLeft, FrontRight, BackLeft, BackRight (quadraphonic)|
|5||FrontLeft, FrontRight, FrontCenter, SideLeft, SideRight (5.0 configuration)|
|6||FrontLeft, FrontRight, FrontCenter, LowFrequency, SideLeft, SideRight (5.1 configuration) (see the following remarks)|
|7||FrontLeft, FrontRight, FrontCenter, LowFrequency, SideLeft, SideRight, BackCenter (6.1 configuration)|
|8||FrontLeft, FrontRight, FrontCenter, LowFrequency, BackLeft, BackRight, SideLeft, SideRight (7.1 configuration)|
|9 or more||No implicit positions (one-to-one mapping)|
If a given voice pair in the audio graph has no speaker positions associated with either its source or target voice (one voice has more than eight channels), neither voice is playable until the source voice has a send matrix set explicitly using the IXAudio2Voice::SetOutputMatrix method. Calling the IXAudio2SourceVoice::Start method for either voice will fail until you do this.
If the source voice and target voice have different numbers of speaker positions and IXAudio2Voice::SetOutputMatrix has not been called on the source voice, XAudio2 sends each source channel to the nearest target speaker (or speakers) available, proportionally to how close they are to the intended speaker. There are two special cases where the default behavior is different.
- If the source audio is mono and is positioned at SPEAKER_FRONT_CENTER or has no defined position, it is always sent to SPEAKER_FRONT_LEFT and SPEAKER_FRONT_RIGHT if they exist in the output audio. If they do not exist, it falls back to the normal case.
- If the source and destination are both 6-channel and are positioned at either of the standard 5.1 speaker setups (Left+Right+Center+Sub+BackL+BackR or Left+Right+Center+Sub+SideL+SideR), channels are mapped through one to one. In other words, SideLeft/Right and BackLeft/Right are treated equivalently. This is because there has been historical confusion around these setups. Therefore, the assumed intent is always to map one to one.