μ-law algorithm

A-law is used in regions where digital telecommunication signals are carried on E-1 circuits, e.g. Europe.

where μ = 255 in the North American and Japanese standards, and sgn(x) is the sign function.

In analog signal transmission, in the presence of relatively constant background noise, the finer detail is lost.

Given that the precision of the detail is compromised anyway, and assuming that the signal is to be perceived as audio by a human, one can take advantage of the fact that the perceived acoustic intensity level or loudness is logarithmic by compressing the signal using a logarithmic-response operational amplifier (Weber–Fechner law).

In telecommunications circuits, most of the noise is injected on the lines, thus after the compressor, the intended signal is perceived as significantly louder than the static, compared to an uncompressed source.

This pre-existing algorithm had the effect of significantly lowering the amount of bits required to encode a recognizable human voice in digital systems.

A sample could be effectively encoded using μ-law in as little as 8 bits, which conveniently matched the symbol size of the majority of common computers.

μ-law encoding effectively reduced the dynamic range of the signal, thereby increasing the coding efficiency while biasing the signal in a way that results in a signal-to-distortion ratio that is greater than that obtained by linear encoding for a given number of bits.

The μ-law algorithm is also used in the .au format, which dates back at least to the SPARCstation 1 by Sun Microsystems as the native method used by the /dev/audio interface, widely used as a de facto standard for sound on Unix systems.

This plot illustrates how μ-law concentrates sampling in the smaller (softer) values.

The μ-law algorithm provides a slightly larger dynamic range than the A-law at the cost of worse proportional distortions for small signals.

Comparison of A-law (blue) and μ-law (red) compression on an input signal (green). Both axes use logarithmic scales in decibels .
μ-law function
Inverse μ-law function
μ-law decoding as generated with the Sun Microsystems C-language routine g711.c commonly available on the Internet