#include <cafe.h>
#include <cafe/axfx.h>

typedef struct _AXFX_DELAY_LINE {
    s32             size;   // Buffer length in samples.  Must be 1 more than maximum delay size.
    f32             *buff;
    s32             delay;  // Delay sample size.  Maximum value must be size-1.
    s32             in;
    s32             out;
    f32             coef;   // Required for allpass

typedef struct _AXFX_MULTI_CH_REVERB {
    // User configurable parameters
    u32 early_mode;          // presets 0 to 4 for early reflections
    u32 late_mode;           // presets 0 to 4 for late reverb
    f32 predelay_time;       // msec 0 to 100
    f32 decay_time;          // sec 0.1 to 20.0
    f32 hf_decay_ratio;      // 0.1 to 1.0
    f32 coloration;          // 0.0 to 1.0
    f32 early_gain;          // 0.0 to 1.0
    f32 late_gain;           // 0.0 to 1.0
    f32 reverb_gain;         // 0.0 to 1.0

    // These are set once to configure the specific reverb algorithm.
    // Derived parameters and objects
    f32 early_level;
    f32 late_level;
    f32 reverb_level;
    // early reflections
    AXFX_DELAY_LINE   early_delay[AXFX_MULTI_CH_MAX_CHANNELS]; // Not all filters use 6 delay lines
    u32               early_tap[AXFX_NUM_ER_TAPS];
    f32               early_coef[AXFX_NUM_ER_TAPS];
    // late reverb
    u32          late_tap;
    f32          cos_w_hf;
    f32          ap_coef;
    AXFX_DELAY_LINE center_delay;
    AXFX_DELAY_LINE      fdn_delay[AXFX_NUM_FDN];
    f32        fdn_fb[AXFX_NUM_FDN];       // feedback coefficients
    f32        fdn_lp_coef[AXFX_NUM_FDN];  // low-pass filter coefficients
    f32        fdn_lp_z[AXFX_NUM_FDN];
    u32 fs;


early_mode Specify an integer value as 0 <= value <= 4. There are five preset arrangements of early reflections. These are designed to emulate different size spaces.

0 = small room
1 = large room
2 = hall
3 = cavern
4 = no early reflection

late_mode Specify an integer value as 0 <= value <= 4. There are five presets that affect the time distribution of reflections in the late reverb.

0 = room
1 = hall
2 = metal corridor
3 = cavern
4 = maximum reverb delay

predelay_time Specify a float value in milliseconds as 0.0 <= value <= 100.0. The predelay time determines the time lag between the sound entering the reverb and the first early reflection. In general, a larger value creates a sense of a larger space.
decay_time Specify a float value in seconds as 0.1 <= value <= 20.0. The decay time is the time it takes the echoes of the late reverb to decrease by 60dB. Of all the parameters, the decay time has the strongest affect on the perceived size of the space. Larger decay times lead to a longer lasting sound, and the sense of a larger space.
hf_decay_ratio Specify a float value as 0.1 <= value <= 1.0. In most spaces high frequencies decay faster than low frequencies. This is due to the reflective properties of most surfaces as well as how sounds are attenuated as they propagate through air. The high frequency decay ratio (hf_decay_ratio) determines the decay time of high frequencies relative to the decay time of low frequencies. For example, when hf_decay_ratio is 0.5, high frequencies will die away twice as fast as low frequencies. When hf_decay_ratio is 1.0 both high and low frequencies will decay at the same rate.
coloration Specify a float value as 0.0 <= value <= 1.0. In a good sounding room the late reverb will not make any particular frequencies stand out, that is it will be colorless. It will also not result in audibly repeating patterns of echoes. However, occasionally it is desirable to design a reverb that does not sound good. For example, a long metal corridor will create patterns of echoes that result in certain frequencies ringing longer. The coloration parameter is useful for adding some of this character to the sound. At 0.0 the reverb should sound colorless, while at 1.0 it will be more colored.
early_gain Specify a float value as 0.0 <= value <= 1.0. The early gain adjusts the overall levels of all the early reflections.
late_gain Specify a float value as 0.0 <= value <= 1.0. The late gain adjusts the overall level of all the late reverb response.
reverb_gain Specify a float value as 0.0 <= value <= 1.0. The reverb gain adjusts the overall levels of all the entire reverb output.
fs If AXFXMultiChReverbGetMemSize is called before AXFXMultiChReverbInit, this must be set to an integer value matching parameter sampleRate passed to AXFXMultiChReverbInit. For more information, see AXFXMultiChReverbGetMemSize. This value is an integer value which represents the sample frequency of the audio the effect operates on. Only a value of 32000 is supported.
mode If AXFXMultiChReverbGetMemSize is called before AXFXMultiChReverbInit, this must be set to parameter mode passed to AXFXMultiChReverbInit. For more information, see AXFXMultiChReverbGetMemSize. This value is an enumerated value which specifies the number of channels the effect operates on.


There are four reverb effects that operate on 2, 4, and 6 channels. Appropriate values must be assigned to the parameters of the AXFX_MULTI_CH_REVERB structure or one of five presets assigned using the AXFXReverbParametersPreset function before the call to AXFXMultiChReverbInit.

Many of the parameters of the reverb interact to create a sense of space. This can make it challenging to choose parameter values. Also some of the parameters, such as the early reflections mode, are subtle, while others are, such as decay time, are quite dramatic. For guidance, experiment with different settings while listening to the resulting sounds.

Memory Requirements

Allocators registered with AXFXGetHooks must return memory aligned on an f32x2 (eight byte) boundary.


The following table lists the CPU utilization given the specified mode and channel settings. The Sound 2 Library Interactive Effects demo displays real time CPU usage metrics from which this data is derived.


See Also

axfxmulticheffects demo
axfxmultichreverbs demo
alleffects demo

Revision History

2014/03/11 CPU metrics
2014/02/26 Add related link.
2013/06/07 Overview section and details added to descriptions.
2013/05/08 Automated cleanup pass.
2013/03/04 New no-reset API.
2012/08/01 Cleanup Pass
2012/05/22 Added reverb effect diagrams.
2012/05/10 Added 2/4/6 channel effects.
2012/04/10 Initial version.