Matrix mixing

Normally when mixing channels, the source channels are sent to the output in the same order; the left input is sent to the left output, and so on. Sometimes something a bit more complex than that is required. For example, if the source has more channels than the output, you may want to "downmix" the source so that all channels are present in the output. Equally, if the source has fewer channels than the output, you may want to "upmix" it so that all output channels have sound. Or you may just want to rearrange the channels. Matrix mixing allows all of these.

A matrix mixer is created on a per-source basis (you can mix'n'match normal and matrix mixing), by using the BASS_MIXER_CHAN_MATRIX and/or BASS_MIXER_CHAN_DOWNMIX flag when calling BASS_Mixer_StreamAddChannel or BASS_Mixer_StreamAddChannelEx. The matrix itself is a 2-dimensional array of floating-point mixing levels, with the source channels on one axis, and the output channels on the other. Some simple examples are shown below.

When using matrix mixing, the source channel's BASS_ATTRIB_VOL attribute still has effect, but the BASS_ATTRIB_PAN attribute does not. Whenever necessary, panning changes can be achieved by modifying the matrix.

When a matrix contains all 0s except for possibly a 1 in each row, that can be applied more simply with channel mapping via BASS_Mixer_ChannelSetMap.

Example

In = stereo, Out = swapped stereo.
float matrix[2][2] = {
    {0, 1}, // left out = right in
    {1, 0} // right out = left in
};
BASS_Mixer_ChannelSetMatrix(handle, matrix); // apply the matrix

In = stereo, Out = swapped stereo, using channel mapping.

int map[2] = {
    1, // left out = right in
    0 // right out = left in
};
BASS_Mixer_ChannelSetMap(handle, map); // apply the channel map

In = stereo, Out = mono.

float matrix[1][2] = {
    {0.5, 0.5} // mono out = half left + right in
};
BASS_Mixer_ChannelSetMatrix(handle, matrix); // apply the matrix

In = stereo, Out = front stereo of quadraphonic (4 channels).

float matrix[4][2] = {
    {1, 0}, // front left out = left in
    {0, 1}, // front right out = right in
    {0, 0}, // rear left out = nothing
    {0, 0} // rear right out = nothing
};
BASS_Mixer_ChannelSetMatrix(handle, matrix); // apply the matrix

In = stereo, Out = front stereo of quadraphonic, using channel mapping.

int map[4] = {
    0, // front left out = left in
    1, // front right out = right in
    -1, // rear left out = nothing
    -1 // rear right out = nothing
};
BASS_Mixer_ChannelSetMap(handle, map); // apply the channel map

In = stereo, Out = duplicated quadraphonic.

float matrix[4][2] = {
    {1, 0}, // front left out = left in
    {0, 1}, // front right out = right in
    {1, 0}, // rear left out = left in
    {0, 1} // rear right out = right in
};
BASS_Mixer_ChannelSetMatrix(handle, matrix); // apply the matrix

In = stereo, Out = duplicated quadraphonic, using channel mapping.

int map[4] = {
    0, // front left out = left in
    1, // front right out = right in
    0, // rear left out = left in
    1 // rear right out = right in
};
BASS_Mixer_ChannelSetMap(handle, map); // apply the channel map

In = 5.1, Out = downmixed stereo (LoRo).

float matrix[2][6] = {
    {1, 0, 0.7, 0, 0.7, 0}, // left out = front left + 0.7x center + 0.7x rear left in
    {0, 1, 0.7, 0, 0, 0.7} // right out = front right + 0.7x center + 0.7x rear right in
};
BASS_Mixer_ChannelSetMatrix(handle, matrix); // apply the matrix

See also

BASS_Mixer_ChannelFlags, BASS_Mixer_ChannelGetMatrix, BASS_Mixer_ChannelSetMap, BASS_Mixer_ChannelSetMatrix, BASS_Mixer_ChannelSetMatrixEx, BASS_Mixer_StreamAddChannel, BASS_Mixer_StreamAddChannelEx