Mixing matrix
One of the most interesting features of AC3Filter is mixing matrix. With help of mixing matrix filter does downmixing and upmixing. But you can use it in much more ways: reassign channels, invert the phase of incorrectly wired speakers, mix LFE to specific channels, etc.
How does mixing matrix work?
Each element of mixing matrix means how much an input channel participate in an output channel. Zero means no influence and one means full loudness. In order, values over 1 means amplification (2 is 6dB louder) and values in between of 0 and 1 means attenuation (0.5 means 6dB quieter). Negative values mean phase inversion (we'll talk about this later).

Let's consider typical 5.1 to stereo down-mixing matrix. It consists of 2 non-zero rows for 2 output channels. All other rows are zero because other channels do not contain any audio:

Left input channel is routed to the left output channel without any change (the cell contains '1'). Left surround is also routed to the left channel without any change so we'll hear right surround as is. Right and right surround channels are routed to the right output respectively:

We should hear the center channel from between of left and right channels. To do this we should route equal amount of the center channel to the left and to the right. But if we mix the center to both front channels it will be louder than just one original center channel! Therefore we should attenuate it. It's why the value of 0.7 is in the mixing matrix:

But... Why 0.7 and not 0.5 (twice quieter)? No, it's not a bug. Loudness is not summed as usual. We must sum the *power* of the signal. Simply talking, we must sum squared amplitudes:
L1 = C^2 - loudness of the center channel in 3 speaker system (one speaker working). L2 = C'^2 + C'^2 - loudness of the center channel in 2 speaker system (2 speakers working).
We want L2 to be equal to L1. Therefore: 2*C'^2 = C^2 C' = 1 / sqrt[2] * C +-= 0.7*C
In general, when we route one channel to N channels, to keep the loudness at the same level we must apply 1/sqrt(N) gain.
Matrix normalization
Note that in the example above we mix several input channels into one output channel. But imagine a loud 'boom' sound reproduced by all channels. In this case when we sum several channels into one, overflow may occur.
Overflow means distortions (see 'Loudness and dynamic range' article for details). What to do if we don't want distortions? We should decrease the sound level. To do this we may decrease Master gain, or lower all values in the matrix. To do this automatically, use matrix normalization. See the result of normalization on 5.1 to stereo downmix matrix:
Not normalized: 
Normalized: 
Normalized matrix looks more complicated, but in fact it does exactly the same thing as unnormalized, just a little quieter. Normalization is enabled by default. For clearness we will use unnormalized matrix afterwards, but for real use, it is better to use normalized matrix.
Maximum level of an output channel equals to the sum of the row elements:
MaxLevel(channel) = Sum(Row(channel))
To avoid overflow we must make the level of all output channels <= 1. To do this we should divide all matrix elements to the maximum level among all channels:
MaxLevel = Max(MaxLevel(channel)) NormalizedMatrix[i][j] = 1/MaxLevel * Matrix[i][j]
That's exactly what matrix normalization option does.
Channel swapping
As we saw before, a row of the matrix means one output channel. So, if we swap two or more rows, it will change speakers’ assignment. We may change left and right speakers simply:

So new matrix will look as:

See that right input channels go to the left speaker and left input channels go to the right speaker.
More complex channel swapping
Well, let's consider a little more complicated example (real). Imagine, that we use the computer in 2 ways: working and watching movies. Room layout is following:

When we working on the computer everything is fine: we hear left sounds from the left speaker, right from the right, etc. But when we want to watch TV resting on the sofa, we must 'rotate' channels assignment. To do this we may use following matrix:

Now we hear center channel from R and SR speakers, left from R, right from SR, left surround from L and right surround from SL. That's exactly what we need from the sofa's point of view. LFE is routed to all channels (we have full-range speakers).
It is a universal matrix for any number of input channels (you may check it yourself).
You may save this matrix for future use:

Also, you can create a preset with rotated matrix and switch between standard and rotated settings fast from tray menu:

... to be continued.
