Lably
Skip to content

Mu-law algorithm

Audio companding algorithm

  • 4 min read
  • 4 chapters

Related on Lably

Through Mu (letter), North America and Japan

The terms PCMU, G711u or G711MU are used for G711 μ-law.

Companding algorithms reduce the dynamic range of an audio signal. In analog systems, this can increase the signal-to-noise ratio (SNR) achieved during transmission; in the digital domain, it can reduce the quantization error (hence increasing the signal-to-quantization-noise ratio). These SNR increases can be traded instead for reduced bandwidth for equivalent SNR.

At the cost of a reduced peak SNR, it can be mathematically shown that μ-law's non-linear quantization effectively increases dynamic range by 33 dB or 5+1⁄2 bits over a linearly-quantized signal, hence 13.5 bits (which rounds up to 14 bits) is the most resolution required for an input digital signal to be compressed for 8-bit μ-law.

Algorithm types

The μ-law algorithm may be described in an analog form and in a quantized digital form.

Continuous

For a given input x, the equation for μ-law encoding is F(x)=sgn⁡(x)ln⁡(1+μ|x|)ln⁡(1+μ),−1≤x≤1,

where μ = 255 in the North American and Japanese standards, and sgn(x) is the sign function. The range of this function is −1 to 1.

μ-law expansion is then given by the inverse equation: F−1(y)=sgn⁡(y)(1+μ)|y|−1μ,−1≤y≤1.

Discrete

The discrete form is defined in ITU-T Recommendation G.711.

G.711 is unclear about how to code the values at the limit of a range (e.g. whether +31 codes to 0xEF or 0xF0). However, G.191 provides example code in the C language for a μ-law encoder. The difference between the positive and negative ranges, e.g., the negative range corresponding to +30 to +1 is −31 to −2. This is accounted for by the use of 1's complement (simple bit inversion) rather than 2's complement to convert a negative value to a positive value during encoding.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and communication