Note: This page has been translated by MathWorks. Please click here

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Dynamic range compressor

**Library:**Audio System Toolbox / Dynamic Range Control

The Compressor block performs dynamic range compression independently across each input channel. Dynamic range compression attenuates the volume of loud sounds that cross a given threshold. The block uses specified attack and release times to achieve a smooth applied gain curve.

The Compressor block processes a signal frame by frame and element by element.

The

*N*-point signal,*x*[*n*], is converted to decibels:$${x}_{\text{dB}}[n]=20\times {\mathrm{log}}_{10}\left|x[n]\right|$$

*x*_{dB}[*n*] passes through the gain computer. The gain computer uses the static compression characteristic of the Compressor block to attenuate gain that is above the threshold.If you specified a soft knee, the gain computer has the following static characteristic:

$${x}_{\text{sc}}({x}_{\text{dB}})=\{\begin{array}{cc}{x}_{\text{dB}}& {x}_{\text{dB}}<\left(T-\frac{W}{2}\right)\\ {x}_{\text{dB}}+\frac{\left(\frac{1}{R}-1\right){\left({x}_{\text{dB}}-T+\frac{W}{2}\right)}^{2}}{2W}& \left(T-\frac{W}{2}\right)\le {x}_{\text{dB}}\le \left(T+\frac{W}{2}\right)\\ T+\frac{\left({x}_{\text{dB}}-T\right)}{R}& {x}_{\text{dB}}>\left(T+\frac{W}{2}\right)\end{array}\text{\hspace{1em}},$$

where

*T*is the threshold,*R*is the compression ratio, and*W*is the knee width.If you specified a hard knee, the gain computer has the following static characteristic:

$${x}_{\text{sc}}({x}_{\text{dB}})=\{\begin{array}{cc}{x}_{\text{dB}}& {x}_{\text{dB}}<T\\ T+\frac{\left({x}_{\text{dB}}-T\right)}{R}& {x}_{\text{dB}}\ge T\end{array}$$

The computed gain,

*g*_{c}[*n*], is calculated as$${g}_{\text{c}}[n]={x}_{\text{sc}}[n]-{x}_{\text{dB}}[n].$$

*g*_{c}[*n*] is smoothed using specified attack and release time parameters:The attack time coefficient,$${g}_{\text{s}}\text{[}n]=\{\begin{array}{cc}{\alpha}_{\text{A}}{g}_{\text{s}}[n-1]+(1-{\alpha}_{\text{A}}){g}_{\text{c}}[n],& {g}_{\text{c}}[n]>{g}_{\text{s}}[n-1]\\ {\alpha}_{\text{R}}{g}_{\text{s}}\text{[}n-1]+(1-{\alpha}_{\text{R}}){g}_{\text{c}}[n],& {g}_{\text{c}}[n]\le {g}_{\text{s}}[n-1]\end{array}$$

*α*_{A}, is calculated asThe release time coefficient,$${\alpha}_{\text{A}}=\mathrm{exp}\left(\frac{-\mathrm{log}(9)}{Fs\times {T}_{\text{A}}}\right)\text{\hspace{0.17em}}.$$

*α*_{R}, is calculated as$${\alpha}_{\text{R}}=\mathrm{exp}\left(\frac{-\mathrm{log}(9)}{Fs\times {T}_{\text{R}}}\right)\text{\hspace{0.17em}}.$$

*T*_{A}is the attack time period, specified by the**Attack time (s)**parameter.*T*_{R}is the release time period, specified by the**Release time (s)**parameter.*Fs*is the input sampling rate, specified by the**Inherit sample rate from input**or the**Input sample rate (Hz)**parameter.If

**Make-up gain (dB)**is set to`Auto`

, the make-up gain is calculated as the negative of the computed gain for a 0 dB input:Given a steady-state input of 0 dB, this configuration achieves a steady-state output of 0 dB. The make-up gain is determined by the$$M={-{x}_{\text{sc}}|}_{{x}_{\text{dB}}=0}.$$

**Threshold (dB)**,**Ratio**, and**Knee width (dB)**parameters. It does not depend on the input signal.The make-up gain,

*M*, is added to the smoothed gain,*g*[_{s}*n*]:$${g}_{\text{m}}[n]={g}_{\text{s}}[n]+M$$

The calculated gain in dB,

*g*[_{dB}*n*], is translated to a linear domain:$${g}_{\text{lin}}[n]={10}^{\left(\frac{{g}_{\text{m}}[n]}{20}\right)}$$

The output of the dynamic range compressor is given as

$$y[n]=x[n]\times {g}_{\text{lin}}[n].$$

[1] Giannoulis, Dimitrios, Michael Massberg, and Joshua D. Reiss. "Digital Dynamic
Range Compressor Design –– A Tutorial And Analysis." *Journal of Audio
Engineering Society*. Vol. 60, Issue 6, 2012, pp. 399–408.

Was this topic helpful?