ArticleslgStudy

computer science

Mu-law algorithm

Mu-law algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Mu-law algorithm rather than just read about it. In short: The μ-law algorithm (sometimes written mu-law, often abbreviated as u-law) is a companding algorithm, primarily used in eight-bit PCM digital telecommunications systems in North America and Japan. It is one of the two companding algorithms in the G.711 standard from ITU-T, the other being the similar A-law.

Mu-law algorithm — main illustration
Mu-law algorithm — illustration

Key takeaways

  • Mu-law algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Mu-law algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Mu-law algorithm from memory before moving on to harder problems.

Reference excerpt

The μ-law algorithm (sometimes written mu-law, often abbreviated as u-law) is a companding algorithm, primarily used in eight-bit PCM digital telecommunications systems in North America and Japan. It is one of the two companding algorithms in the G.711 standard from ITU-T, the other being the similar A-law. A-law is used in regions where digital telecommunication signals are carried on E-1 circuits, e.g. Europe. 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 , {\displaystyle F(x)=\operatorname {sgn}(x){\dfrac {\ln(1+\mu |x|)}{\ln(1+\mu )}},\quad -1\leq x\leq 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. {\displaystyle F^{-1}(y)=\operatorname {sgn}(y){\dfrac {(1+\mu )^{|y|}-1}{\mu }},\quad -1\leq y\leq 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.

Implementation The μ-law algorithm may be implemented in several ways:

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 that 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. Software/DSP Use the continuous version of the μ-law algorithm to calculate the companded values.

Usage justification μ-law encoding is used because speech has a wide dynamic range. 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 became a common solution, and thus, prior to common digital usage, the μ-law specification was developed to define an interoperable standard. 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. The au format is also used in various common audio APIs, such as the classes in the sun.audio Java package in Java 1.1 and in some C# methods. This plot illustrates how μ-law concentrates sampling in the smaller (softer) values. The horizontal axis represents the byte values 0-255, and the vertical axis is the 16-bit linear decoded value of μ-law encoding.

… excerpt ends here. Continue reading the full article.

Illustrations

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

Worked examples

Example 1 — a first encounter with Mu-law algorithm

Start with the simplest possible case. Write down what Mu-law algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Mu-law algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Mu-law algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Mu-law algorithm

In research
Mu-law algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Mu-law algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Mu-law algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Audio codecs, Data compression, ITU-T recommendations, so understanding it makes those chapters shorter.
In everyday life
Look for Mu-law algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Mu-law algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Mu-law algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Mu-law algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Mu-law algorithm in simple terms?

The μ-law algorithm (sometimes written mu-law, often abbreviated as u-law) is a companding algorithm, primarily used in eight-bit PCM digital telecommunications systems in North America and Japan. It is one of the two companding algorithms in the G.711 standard from ITU-T, the other being the simil…

Why does Mu-law algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Mu-law algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Mu-law algorithm.

Tags

  • Audio codecs
  • Data compression
  • ITU-T recommendations

Keep exploring