MIX Overview

The MIX library is an optional abstraction layer for AX that provides the following logical mixer controls:

Rather than manipulate the low-level volume parameters of every voice, applications can use the high-level controls provided by MIX.

MIX also calculates volume ramps automatically, to prevent "zipping" and "popping" artifacts when attenuation and panning changes are applied to a voice.


MIX may be used to assign mixer controls to individual voices acquired from AX. Each voice receives separate mixer controls for each output device, so each voice can be mixed with different parameters to one or more output devices simultaneously.

Mixer Layer

Attenuation and Gain

All attenuation and gain values are expressed as signed integers, quantized in 0.1 dB increments (A value of 1 in gain is 0.1 dB).

The mixer clamps the actual values to −90.4 dB and +6.0 dB to accommodate the mixing range for Cafe's DSP. Attenuation and gain values outside this range will be clamped into it. The decibel values are expressed as signed 32-bit integers. Note that overflow errors may result from careless adjustments.


MIX functions are not thread-safe. To use these, call the MIX library functions only from within an AX frame callback. See the Mix Multi-Channel Demo for an example of how to use the library.

After a mixer channel is assigned to a voice, do not use the AXSetVoiceDeviceMix, AXSetVoiceVe, or AXSetVoiceVeDelta functions to change the mixing and volume parameters for the voice. MIX sets these AX parameters based on the MIX settings for the voice. Changing these parameters may result in unexpected behavior.

Source Code

Source code is released as part of the SDK at ($CAFE_ROOT)/system/src/demo/snd_user_rpl/mix/

For more information, see AX Programming Model.

Mixing Modes

MIX supports different mixing modes for different devices. The mixing mode must correspond to the appropriate AX mode:

MIX mode Device Description AX Mode
MIX_SOUND_MODE_MONO TV, DRC, RMT Pan and SPan are ignored by the mixer. AX_MODE_STEREO
MIX_SOUND_MODE_STEREO TV, DRC Pan settings apply. Sounds are mixed to 2 channels. AX_MODE_STEREO
MIX_SOUND_MODE_SURROUND DRC Pan and SPan settings apply. Sounds are mixed to 4 channels for DRC surround sound. AX_MODE_SURROUND
MIX_SOUND_MODE_6CHAN TV Pan, SPan, and LFE settings apply. Sounds are mixed to 6 channels for TV surround sound. AX_MODE_6CHAN

Voice Mixing Controls


The input controls the amount of gain applied to the input signal. Applications can modify this control to apply effects such as an ADSR envelope, tremolo, volume attenuation, or a sum of all these to the voice. This control is set to 0 dB by default.


The mute control sets infinite attenuation to the input. Unmuting the control restores input attenuation. This control is set to unmute by default.

AuxA, AuxB, AuxC, and Post/Prefader

The AUX controllers set the amount of gain from the input voice to be applied to the corresponding AUX bus. This can be switched to postfader or prefader mode, which determines whether fader attenuation applies to the AUX bus input. In postfader mode, the fader's volume attenuation is applied to the AUX bus input. In prefader mode, it is not. This control is set to −96 dB for all AUX buses and postfader mode by default. AUX attenuation is applied as follows:

post fader attendB = AUX attendB + fader attendB
pre fader attendB = AUX attendB

Equation 1 - AUX attenuation


The pan control distributes the input signal to the left and right channels. 0 is left, 64 is center, and 127 is right. This control is set to 64 by default. Attenuation is applied as follows:

left channel attendB = -20 * log10(sqrt ((127 - pan) / 127))
right channel attendB = 20 * log10(sqrt (pan / 127))

Equation 2 - Pan attenuation


The SPan control distributes the input signal to front and surround channels. 0 is surround, 64 is center, and 127 is front. This control is set to 127 by default. Attenuation is applied as follows:

surround channel attendB = -20 * log10(sqrt ((127 - pan) / 127))
front channel attendB = 20 * log10(sqrt (pan / 127))

Equation 3 - SPan attenuation


The LFE control attenuates a voice's output to the LFE channel. It applies in addition to the fader control. This control is set to −96dB by default.


The fader control attenuates a voice's output to the main bus. A voice's post/prefader setting determines whether the fader's attenuation applies to AUX buses as well. This control is set to 0 dB by default.

Mixer application notes

Volume ramping

When a change is made to a voice's volume, it is ramped over the course of one audio frame to mitigate "pop" or "zip" artifacts induced by fast changes in volume. The new volume level will be reached on the subsequent audio frame to allow time for ramping to occur.

Suggested use of input and fader controls

Adjusting the input control consumes fewer cycles than using the fader and pan controls. Programmers may use these in whatever manner is most efficient.

For the most part, sound effects and audio streams may have their faders to 0 dB and use the input control to fade volume.

A music synthesizer may calculate attenuation for ADSR envelope, LFO volume modulation, MIDI channel volume, expression pedal volume, and master volume for the input control while setting the fader to 0 dB and using the pan control as per the MIDI specification. However, depending on the type of application (and if the MIDI master volume, channel volume, and expression pedal seldom changes), it may be possible to sum these attenuations and apply them to the input to save cycles on the synthesizer during playback.

Using the Mixer Functions

The diagram below illustrates the relationship between various MIX functions and the mixer controls. For brevity, only a single output device is shown.

The MIXCntrl Structure

The MIXCntrl structure is used to pass mixer control values to the MIXInitDeviceControl initialization function.

typedef struct 
    s16 aux[AX_AUX_ID_MAX_NUM]; // aux send values in 0.1dB
    s16 pan;
    s16 span;
    s16 fader;
    s16 lfe;

This structure is defined within the <cafe/mix.h> header file.


Library Version Availability
Sound 2.0 Yes
Sound 1.0 Yes

See Also

AX Data Structures and Definitions Overview
AX Overview

Revision History

2013/05/08 Automated cleanup pass.
2012/01/26 Update to Audio API v2.0.
2011/02/21 Initial Version