# Matrix Mixer/Router¶

## Case Studies¶

Currently (as of 2010-01-30) the matrix≈ objects mixes M incoming multichannel signals to N multchannel outputs. We also need to be able to do mixing *inside* one multichannel signal. Some case studies might be productive for further discussions and design decisions.

### Mono to Stereo Mixing¶

1 incomming multichannel signal containing 1 channel

1 outgoing multichannel signal containing 2 channels

Internally we need a 1x2 matrix.

### Stereo to Surround Upmixing¶

1 incomming multichannel signal containing 2 channel

1 outgoing multichannel signal containing 5 channels

Internally we need a 2x5 matrix.

### Ambisonic Encoding¶

1 incomming multichannel signal containing 5 channel (5 mono sources)

1 outgoing multichannel signal containing 16 channels (3rd order B-format)

Internally we need a 5x16 matrix

### Ambisonic Encoding Enhanced with Reverb for Distance Emulation¶

In this example we want to emulate distance by attenuating the signal with increasing distance, and introduce reverb, so that the ration between wet signal (reverb) and dry increase with increasing distance.

1 incomming multichannel signal containing 5 channel (5 mono sources)2 outgoing multichannel signals:

- One for dry: 16 channels (3rd order B-format)
- One for reverb: 4 channels (1st order B-format)

In this example we internally will need a 5x20 matrix, with the output signals sliced to two output signals, one for the dry return (16) and another one for the wet (4 channels)

### The Mighty Mixer¶

This works the way a DAW mixer should have worked:

- We have multiple input signals, each of which can be multi-channel, e.g. mono, stereo, 5.1 or 1st or higher order B-format.
- We have multiple outlets: busses, submixes and main. Each of them can be any number of channels, depending on what spatialisation format they are sending; mono, stereo, 5.1, 1st or higher order B-format, decoded signals for N channels, etc..

If we for instance have 4 multichannel inputs: mono, stereo, B-format and surround, we have a total of `1+2+4+5 = 12`

input channels.

If this is mixed to a 9-channel B-format subgroup (for 2nd order encoded recording) and 16 loudspeakers, we have a total of `9 + 16 = 25`

output channels. The internal matrix could then be conceived as a 12x25 matrix, or as a 4x2 *matrix of matrixes*.

## Object oriented mixing?¶

Based on the last example above, an object-oriented approach to mixing starts emerging. We could then have basic matrix class:

### :matrix¶

1 multichannel inlet with M inlets

1 multichannel outlet with N outlets

Performs a basic MxN matrix operation

When matrix coefficients change, it interpolates over a set time for smoothnes

### :spatdif¶

A class with properties and methods as specified by SpatDIF

## Spatialisation classes¶

Spatialisation classes inherit from `:matrix`

and `:spatdif`

, and add methods for determining the matrix coefficients, depending on whatever properties and methods the spatialisation algorithm requires. Some straight-forward examples are:

### :pan¶

1x2 matrix with constant intensity panning

### :upmix¶

Mono or stereo to surround

### :ambidecode¶

Decoding 1st or higher order ambisonics signals

### :ambiencode¶

1st or higher order ambisonic encoding

### :vbap¶

Vector-base amplitude panning

### :dbap¶

Distance-based amplitude panning

## Some more advanced examples of spatialisation classes¶

The previous examples are all matrix-based (linear algebra) spatialisation methods. The following examples are more composite, either daisy-chaining several matrices, or performing additional effect processes, such as delays, filtering and convolution.

### :binaural¶

Binaural encoding using filters, convolution or similar.

### :ambiToBinaural¶

Also inherits from `:ambidecode`

and `:binaural`

. It first decodes to a set number of speakers, and next binaurally encode each of the speaker channels.

### :ViMiC¶

This one expands on the matrix by also internally introducing delays, filtering, etc., inherited from other Jamoma DSP classes. But within the scope of mixing, these processes remains internal and transparent to the mixer.

## Mighty Mixer as Meta-Matrix¶

From the above it is clear that it will be limiting to conceive the Mighty Mixer to be a matrix only. This would restrict it from being able to work with e.g. binaural and ViMiC. Instead the Mighty Mixer is a meta-matrix, performing matrix operations on MMxNN *multichannel* signals; a matrix of matrixes.

In the above example with 4 multichannel inputs (mono, stereo, B-format and surround) routed to two multichannel outputs (2nd order B-format as well as 16 speakers), we will be operating on the following meta-matrix:

1x9 | 2x9 | 4x9 | 5x9 |

1x16 | 2X16 | 4x16 | 5x16 |

The Mighty Mixer hence inherits from `:matrix`

and `:spatdif`

as well as the various spatialisation classes.