Mu-law algorithm

From Wikipedia, the free encyclopedia

Graph of μ-law & A-law algorithms
Enlarge
Graph of μ-law & A-law algorithms

The mu-law algorithm (μ-law) is a companding algorithm, primarily used in the digital telecommunication systems of North America and Japan. Its purpose is to reduce the dynamic range of an audio signal. In the analog domain, this can increase the signal to noise ratio achieved during transmission, and in the digital domain, it can reduce the quantization error (hence increasing signal to quantization noise ratio).

It is similar to the A-law algorithm used in Europe.

Contents

[edit] Algorithm Types

There are two forms of this algorithm - an analog version, and a quantized digital version.

[edit] Analog

For a given input x, the equation for μ-law encoding is as follows,

F(x) = \sgn(x) \frac{\ln(1+ \mu |x|)}{\ln(1+\mu)}~~~~-1 \leq x \leq 1[citation needed],

where μ = 255 (8 bits) in the North American and Japanese standards.

μ-law expansion is then given by the inverse equation:

F^{-1}(y) = \sgn(y) (1 / \mu ) [(1 + \mu)^{|y|}- 1]~~~~-1 \leq y \leq 1[citation needed]

[edit] Digital

This is defined in ITU-T Recommendation G.711

Quantized μ-law algorithm
13 bit Binary Linear input code 8 bit Compressed code
+8159 to +4063 in 16 intervals of 256 0x80 + interval number
+4063 to +2015 in 16 intervals of 128 0x90 + interval number
+2015 to +991 in 16 intervals of 64 0xA0 + interval number
+991 to +479 in 16 intervals of 32 0xB0 + interval number
+479 to +223 in 16 intervals of 16 0xC0 + interval number
+223 to +95 in 16 intervals of 8 0xD0 + interval number
+95 to +31 in 16 intervals of 4 0xE0 + interval number
+31 to +1 in 15 intervals of 2 0xF0 + interval number
0 0xFF
-31 to -1 in 15 intervals of 2 0x70 + interval number
-95 to -31 in 16 intervals of 4 0x60 + interval number
-223 to -95 in 16 intervals of 8 0x50 + interval number
-479 to -223 in 16 intervals of 16 0x40 + interval number
-991 to -479 in 16 intervals of 32 0x30 + interval number
-2015 to -991 in 16 intervals of 64 0x20 + interval number
-4063 to -2015 in 16 intervals of 128 0x10 + interval number
-8159 to -4063 in 16 intervals of 256 0x00 + interval number

[edit] Implementation

There are three ways of implementing a μ-law algorithm :

Analog
Use an amplifier with non-linear gain to achieve companding entirely in the analog domain.
Non-linear ADC
Use an Analog to Digital Converter with quantization levels which are unequally spaced to match the μ-law algorithm.
Digital
Use the quantized digital version of the μ-law algorithm to convert data once it is in the digital domain.

[edit] Usage Justification

This encoding is used because speech has a wide dynamic range. In the analog world, when mixed with a relatively constant background noise source, 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 perceived intensity (loudness) is logarithmic[citation needed] by compressing the signal using a logarithmic-response op-amp. In telco circuits, most of the noise is injected on the lines, thus after the compressor, the intended signal will be perceived as significantly louder than the static, compared to an un-compressed source. This became a common telco solution, and thus, prior to common digital usage, the mu-law specification was developed to define an inter-compatible standard.

As the digital age dawned, it was noted that this pre-existing algorithm had the effect of significantly reducing the number of bits needed to encode recognizable human voice. Using mu-law, a sample could be effectively encoded in as few as 8 bits, a sample size that conveniently matched the symbol size of most standard computers.

Mu-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. This is an early form of perceptual audio encoding.

The mu-law algorithm is also used in the .au format (which dates back at least to the Sparcstation I as the native method used by Sun's /dev/audio interface which was widely used as a defacto "standard" for unix sound), various common audio APIs (such as the classes in the sun.audio Java package in Java 1.1, and in some C# methods).

[edit] Comparison with A-law

The A-law algorithm provides a slightly larger dynamic range than the mu-law at the cost of worse proportional distortion for small signals. By convention, A-law is used for an international connection if at least one country uses it.

This article contains material from the Federal Standard 1037C, which, as a work of the United States Government, is in the public domain.

[edit] See also

[edit] External links

In other languages