USB Audio Project: Setting up the Matrix Mixer in mixer.xc

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
Post Reply
bobbylala
Junior Member
Posts: 6
Joined: Wed Apr 17, 2019 12:53 pm

USB Audio Project: Setting up the Matrix Mixer in mixer.xc

Post by bobbylala »

Hello,

I am working on a USB audio project and would like to make use of the Digital Mixer included in the USB Audio Reference Design. The document that accompanies the software (Doc. No. XM0088546.1) briefly describes the Digital Mixer and its control channel - namely:
Command Description
SET_SAMPLES_TO_HOST_MAPSets the source of one of the audio streams going to the
host.
SET_SAMPLES_TO_DEVICE_MAP Sets the source of one of the audio streams going to the
audio driver.
SET_MIX_MULT Sets the multiplier for one of the inputs to a mixer.
SET_MIX_MAP Sets the source of one of the inputs to a mixer.
SET_MIX_IN_VOL If volume adjustment is being done in the mixer, this
command sets the volume multiplier of one of the USB
audio inputs.
SET_MIX_OUT_VOL If volume adjustment is being done in the mixer, this
command sets the volume multiplier of one of the USB
audio outputs.
There is a short example in the document for controlling the matrix from the Host PC but I would like to control the matrix internally - so rerouting the control channel "c_mix_ctl" from Endpoint0 to my own processing in the XMOS device.

Code: Select all

case SET_MIX_MULT:
    mix = inuint(c_mix_ctl);
    index = inuint(c_mix_ctl);
    val = inuint(c_mix_ctl);
    inct(c_mix_ctl);

    write_word_to_mix_mult(mix, index, val);
    break;

case SET_MIX_MAP:
    mix = inuint(c_mix_ctl);
    index = inuint(c_mix_ctl); /* mixer input */
    val = inuint(c_mix_ctl);   /* source */
    inct(c_mix_ctl);
#ifdef FAST_MIXER
    setPtr(index, val, mix);
#else
    write_word_to_mix_map(mix, index, val);
This is the source from mixer.xc showing what happens when the SET_MIX_MULT or SET_MIX_MAP commands are received. Can anyone tell me how the parameters "mix", "index" and "val" relate to the mix matrix? There is little documentation on how the matrix is arranged i.e. which cells relate to which input or output.

Any pointers to additional documentation would be useful. Hope someone can help, cheers!


ffomich
Experienced Member
Posts: 119
Joined: Mon Sep 15, 2014 1:32 pm

Post by ffomich »

Hi bobbylala,
please see the structure of the mixer matrix for my example:

Code: Select all

// routing in mixer
// 2 inputs:   Analog, Digital
// 3 outputs:  Analog + USB out, Digital + USB out, Analog2 (DAC) + USB out

//mixer1Weigth[]
// assume NUM_USB_CHAN_OUT = 2 and NUM_USB_CHAN_IN = 2 - number of audio channels in USB stream

//                                                  1            2            3          4           5           6 ( (MAX_MIX_COUNT))
// #1                       DAW-Analogue1 ->    0:[  U1  ]  1:[ -inf ]  2:[  U3  ]  3:[ -inf ]  4:[  U5  ]  5:[ -inf ]
// #2(=NUM_USB_CHAN_OUT)    DAW-Analogue2 ->    6:[ -inf ]  7:[  U2  ]  8:[ -inf ]  9:[  U4  ] 10:[ -inf ] 11:[  U6  ]
// #1                       AUD-Analogue1 ->   12:[T_AN1 ] 13:[ -inf ] 14:[T_AN3 ] 15:[ -inf ] 16:[T_AN5 ] 17:[ -inf ]
// #2                       AUD-Analogue2 ->   18:[ -inf ] 19:[T_AN2 ] 20:[ -inf ] 21:[T_AN4 ] 22:[ -inf ] 23:[T_AN6 ]
// #3                       AUD-Digital1  ->   24:[T_DIG1] 25:[ -inf ] 26:[T_DIG3] 27:[ -inf ] 28:[T_DIG5] 29:[ -inf ]
// #4(=NUM_CHAN_IN)         AUD-Digital2  ->   30:[ -inf ] 31:[T_DIG2] 32:[ -inf ] 33:[T_DIG4] 34:[ -inf ] 35:[T_DIG6]
//                                                  |            |            |           |          |           |
//                                               Mix OUT1     Mix OUT2     Mix OUT3    Mix OUT4   Mix OUT5    Mix OUT6
//                                                  |____________|            |____________|         |____________|
//                                                         |                         |                     |
//                                                    Analogue OUT              Analogue OUT 2         Digital OUT
The rows are mono inputs. In this matrix we have: USB playback (stereo) + Analog input (stereo) + AES input (stereo).
The columns are mono outputs. In this matrix we have: Analog output #1(stereo) + Analog output #2(stereo) + AES output (stereo).

SET_MIX_MULT write the volume coefficient 'val' (from -inf to 1.00) into the cell with index = 'index'.
If I write 1.00 into the matrix[2] cell (U3=1.00), I hear USB playback Left channel audio from the Analog Output #2 Left channel.
Post Reply