Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Μ-law algorithm
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Audio companding algorithm}} {{more footnotes needed|date=May 2018}} {{lowercase title}} [[File:Comparison of A-law and μ-law compression on an input signal.svg|thumb|Comparison of [[A-law]] (blue) and [[μ-law]] (red) [[Dynamic range compression|compression]] on an input signal (green). Both axes use [[logarithmic scale]]s in [[decibel]]s.|350x350px]] {{Listen | type = speech | header = Audio quality comparison | filename = Speech 12dB s16.flac | title = 16-bit linear PCM (reference/original) | filename2 = Speech 12dB mulaw8.flac | title2 = 8-bit µ-law PCM | filename3 = Speech 12dB u8.flac | title3 = 8-bit linear PCM }} The '''μ-law algorithm''' (sometimes written '''[[Mu (letter)|mu]]-law''', often abbreviated as '''u-law''') is a [[companding]] algorithm, primarily used in 8-bit [[PCM]] [[Digital data|digital]] [[telecommunications system]]s 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.<ref>{{cite web |url=http://www.grandstream.com/support/faq/common-questions/video/voice/speech-codecs |title=Video/Voice/Speech Codecs |website=Grandstream| access-date= 19 July 2020}}</ref> 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 (signal processing)|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 {{Fraction|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.<ref>{{Cite web |last=Ess |first=David Van |date=2014-12-29 |orig-date=2007-10-09 |title=Cypress Semiconductor AN2095: Algorithm - Logarithmic Signal Companding - Not Just a Good Idea - It Is μ-Law |url=https://www.infineon.com/dgdl/Infineon-AN2095_Algorithm_Logarithmic_Signal_Companding_Not_Just_a_Good_Idea_It_Is_-Law-ApplicationNotes-v05_00-EN.pdf?fileId=8ac78c8c7cdc391c017d073725525a59 |url-status=live |archive-url=https://web.archive.org/web/20221006014433/https://www.infineon.com/dgdl/Infineon-AN2095_Algorithm_Logarithmic_Signal_Companding_Not_Just_a_Good_Idea_It_Is_-Law-ApplicationNotes-v05_00-EN.pdf?fileId=8ac78c8c7cdc391c017d073725525a59 |archive-date=2022-10-06 |access-date=2023-06-28 |website=[[Infineon Technologies]]}}</ref> ==Algorithm types== The μ-law algorithm may be described in an analog form and in a quantized digital form. ===Continuous=== [[File:Mu-law function.svg|thumb|μ-law function|350x350px]] [[File:Inverse mu-law function.svg|thumb|Inverse μ-law function|350x350px]] For a given input {{mvar|x}}, the equation for μ-law encoding is<ref name="mulaw-equation">{{cite web |url=https://www.cisco.com/c/en/us/support/docs/voice/h323/8123-waveform-coding.html |title=Waveform Coding Techniques - Cisco |access-date=2020-12-07 |date=2006-02-02}}</ref> <math display="block"> F(x) = \sgn(x) \dfrac{\ln(1 + \mu |x|)}{\ln(1 + \mu)}, \quad -1 \leq x \leq 1, </math> where {{math|1=''μ'' = 255}} in the North American and Japanese standards, and {{math|1=sgn(''x'')}} is the [[sign function]]. The [[Range of a function|range]] of this function is −1 to 1. μ-law expansion is then given by the inverse equation:<ref name="mulaw-equation" /> <math display="block"> F^{-1}(y) = \sgn(y) \dfrac{(1 + \mu)^{|y|} - 1}{\mu}, \quad -1 \leq y \leq 1. </math> ===Discrete=== The discrete form is defined in ITU-T Recommendation [[G.711]].<ref>{{cite web |url=http://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-G.711-198811-I!!PDF-E&type=items |title=ITU-T Recommendation G.711}}</ref> 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).{{citation needed|date=October 2016}} However, G.191 provides example code in the [[C language]] for a μ-law encoder.<ref>{{Cite web|url=https://www.itu.int/rec/T-REC-G.191/en|title=G.191 : Software tools for speech and audio coding standardization|website=www.itu.int}}</ref> 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. {| class="wikitable" |+ Quantized μ-law algorithm ! 14-bit binary linear input code !! 8-bit compressed code |- | +8158 to +4063 in 16 intervals of 256 || 0x80 + interval number |- | +4062 to +2015 in 16 intervals of 128 || 0x90 + interval number |- | +2014 to +991 in 16 intervals of 64 || 0xA0 + interval number |- | +990 to +479 in 16 intervals of 32 || 0xB0 + interval number |- | +478 to +223 in 16 intervals of 16 || 0xC0 + interval number |- | +222 to +95 in 16 intervals of 8 || 0xD0 + interval number |- | +94 to +31 in 16 intervals of 4 || 0xE0 + interval number |- | +30 to +1 in 15 intervals of 2 || 0xF0 + interval number |- | 0 || 0xFF |- | −1 || 0x7F |- | −31 to −2 in 15 intervals of 2 || 0x70 + interval number |- | −95 to −32 in 16 intervals of 4 || 0x60 + interval number |- | −223 to −96 in 16 intervals of 8 || 0x50 + interval number |- | −479 to −224 in 16 intervals of 16 || 0x40 + interval number |- | −991 to −480 in 16 intervals of 32 || 0x30 + interval number |- | −2015 to −992 in 16 intervals of 64 || 0x20 + interval number |- | −4063 to −2016 in 16 intervals of 128 || 0x10 + interval number |- | −8159 to −4064 in 16 intervals of 256 || 0x00 + interval number |} ==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 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. ; 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 [[Channel coding|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. [[File:Ulaw.JPG|thumb|400px|right|μ-law decoding as generated with the Sun Microsystems C-language routine g711.c commonly available on the Internet]] The μ-law algorithm is also used in the [[Au file format|.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 [[API]]s such as the classes in the sun.audio [[Java package]] in [[Java platform|Java]] 1.1 and in some [[C Sharp (programming language)|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. ==Comparison with A-law== The μ-law algorithm provides a slightly larger dynamic range than the A-law at the cost of worse proportional distortions for small signals. By convention, A-law is used for an international connection if at least one country uses it. ==See also== * [[Dynamic range compression]] * [[Signal compression (disambiguation)]] * [[G.711]], a waveform speech coder using either A-law or μ-law encoding * [[Tapered floating point]] ==References== <references/> {{FS1037C}} ==External links== * [http://www.cisco.com/en/US/tech/tk1077/technologies_tech_note09186a00801149b3.shtml Waveform Coding Techniques] – details of implementation * [http://focus.ti.com/lit/an/spra163a/spra163a.pdf A-Law and mu-Law Companding Implementations Using the TMS320C54x] ([[PDF]]) * [http://focus.ti.com/lit/an/spra634/spra634.pdf TMS320C6000 μ-Law and A-Law Companding with Software or the McBSP] ([[PDF]]) * [https://web.archive.org/web/20110719132013/http://hazelware.luggle.com/tutorials/mulawcompression.html A-law and μ-law realisation (in C)] * [https://github.com/deftio/companders u-law implementation in C-language with example code] {{Compression Methods}} {{Compression formats}} {{Authority control}} {{Use dmy dates|date=September 2024}} {{DEFAULTSORT:Mu-Law Algorithm}} [[Category:Audio codecs]] [[Category:ITU-T recommendations]] [[Category:Data compression]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Authority control
(
edit
)
Template:Citation needed
(
edit
)
Template:Cite web
(
edit
)
Template:Compression Methods
(
edit
)
Template:Compression formats
(
edit
)
Template:FS1037C
(
edit
)
Template:Fraction
(
edit
)
Template:Listen
(
edit
)
Template:Lowercase title
(
edit
)
Template:Math
(
edit
)
Template:More footnotes needed
(
edit
)
Template:Mvar
(
edit
)
Template:Short description
(
edit
)
Template:Use dmy dates
(
edit
)