Matrix mixer

nu774 edited this page Sep 13, 2013 · 5 revisions

You can play with fully customizable matrix mixer either by --matrix-preset or --matrix-file option. In both cases, you have to prepare a text file containing matrix spec.

You can directly pass path name of the matrix file with --matrix-file. On the other hand, --matrix-preset searches the file from pre-defined directories. As the option name implies, this is designed so that you can create your own preset files, and specify with their names.

--matrix-preset=foo searches the following files, in the following order.

  1. %HOME%\.qaac\matrix\foo.txt (%HOME% is environment variable. Be careful a dot before qaac)
  2. %APPDATA%\qaac\matrix\foo.txt (%APPDATA% is Application Data directory for the login user. Be careful a dot is not here)
  3. (path to qaac directory)\matrix\foo.txt

The file format is very simple, and is like the following:

1 0 0.7071
0 1 0.7071

This a 2x3 matrix, and can be used for 3ch to 2ch downmix. Each row corresponds to output channels (L and R). Similarly, each column corresponds to input channels (L, R, and C). You have to separate each column by one or more space/tabs.

With this matrix, each output channel will be calculated from input as following:

L = 1 * L + 0 * R + 0.7071 * C
R = 0 * L + 1 * R + 0.7071 * C

Actually, each coefficient in the matrix will be automatically "normalized" to prevent clipping. That is, they are scaled so that sum of coefficients corresponding to each output channel will be 1. This can be formulated as the following:

M_ij = M_ij / (abs(M_i1) + abs(M_i2) + .... + abs(M_in))

where M_ij is matrix coefficient.

You can disable this automatic scaling with --no-matrix-normalize option.

The following is one more example.

1 0 0.7071 0 -0.87178j -0.4899j
0 1 0.7071 0 0.4899j 0.87189j

This is 2x6 matrix, therefore can be used for downmixing 6ch to 2ch.

Here, imaginary value with "j" is used. You can use real value, or pure imaginary value like this(with j), for each matrix element. Imaginary value means 90 degree phase shifting, and it's real coefficient means gain of the channel.

If you want to achieve the pure effect of phase shift, try something like this:


This 1x1 matrix transforms mono input to mono output, applying 90 degree phase shift, known as Hilbert transform.

Please note that qaac will always use default channel layout for the remixed result. If you want other than default channel layout for the output number of channels, use --chanmask to let qaac know the desired channel layout.


You cannot write imaginary unit as j. Instead, use 1j or 1.0j. This is a restriction by current lexer implementation.

You cannot specify both non-zero real and imaginary value for the same input channel (that is, on the same column).


The two matrix above is fine. However,


This is not allowed. This restriction is by implementation reason. You won't need this for practical use case anyway.