Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a21c926ab8623191

Jump to content

Talk:A-law algorithm

Page contents not supported in other languages.
Add topic
From Wikipedia, the free encyclopedia
Latest comment: 1 month ago by Jurjen B in topic Value of A

Talk

[edit]

how does the a-law algorithm look like? What's the difference to the mu-law algorithm? --Abdull 17:08, 4 Apr 2005 (UTC)

equation

[edit]

This needs finishing:

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

It's not quite right. Check the external links and such. - Omegatron 15:12, May 24, 2005 (UTC)

retransformation wrong  ?

[edit]

I know these formulas are in many documents but I'm afraid the 2nd is wrong.

I tried to build a VoIP (SIP) phone with A-Law audio codec. And I was very surprised because the decoded A-Law stream was very silent. I used exactly these formulas. And I think there is a mistake. Assume x = 1 then:

But the retransformation gives

I think the A must be the denominator in both cases:

i.e.


Joerg Anders (GERMANY)

a or A

[edit]

Is it a-law or A-law and what (if anything) does the a/A stand for? --Abdull 16:54, 11 August 2006 (UTC)

Legend of the graph uses wrong colours

[edit]

The green straight line corresponds to no companding... 192.54.144.226 08:11, 22 August 2006 (UTC)Denis

Whoops - You are right - It's fixed now Ozhiker 08:35, 22 August 2006 (UTC)

The graph gives now the impression that not every linear signal value is mapped into a quantized value. This impression is incorrect because ofcourse for every input there will be a quantized output. Bob.v.R (talk) 05:14, 2 November 2019 (UTC)Reply

Interoperability

[edit]

The article states: "A-law is used for an international connection if at least one country uses it." Wouldn't both ends of the connection need to support the algorithm to send signals using it? Or am i missing something? Foobaz·o< 17:35, 17 May 2007 (UTC)

Maybe it could be worded more clearly - If either country uses A-law as their standard companding, then the companding rule when calls are made between the countries must be A-law. e.g. The UK uses A-Law for their standard companding, the USA uses u-Law. Hence because one uses A-Law, then all calls from the USA to UK or UK to USA must use A-Law. e.g.(2) Canada uses u-Law for their standard companding, the USA also uses u-Law. Hence they use u-Law companding on calls between the two countries becuase neither uses A-Law. --Ozhiker 22:19, 17 May 2007 (UTC)

Encoding table

[edit]

I created an encoding table from "unsigned linear 16 bit" values into A-law 8 bit values. Some self-written programs generates the example data and does the pretty printing and SoX did the A-law encoding.
c is an intermediate value after the compression, that is given here to make the encoding better to understand. The final A-law-encoded value is the unintuitively result of: c XOR 55ₕₑₓ.

A-law encoding table
u16cA-lawRange size
0x0000 ... 0x03FF7F2A1024 values
0x0400 ... 0x07FF7E2B1024 values
0x0800 ... 0x0BFF7D281024 values
0x0C00 ... 0x0FFF7C291024 values
0x1000 ... 0x13FF7B2E1024 values
0x1400 ... 0x17FF7A2F1024 values
0x1800 ... 0x1BFF792C1024 values
0x1C00 ... 0x1FFF782D1024 values
0x2000 ... 0x23FF77221024 values
0x2400 ... 0x27FF76231024 values
0x2800 ... 0x2BFF75201024 values
0x2C00 ... 0x2FFF74211024 values
0x3000 ... 0x33FF73261024 values
0x3400 ... 0x37FF72271024 values
0x3800 ... 0x3BFF71241024 values
0x3C00 ... 0x3FFF70251024 values
0x4000 ... 0x41FF6F3A512 values
0x4200 ... 0x43FF6E3B512 values
0x4400 ... 0x45FF6D38512 values
0x4600 ... 0x47FF6C39512 values
0x4800 ... 0x49FF6B3E512 values
0x4A00 ... 0x4BFF6A3F512 values
0x4C00 ... 0x4DFF693C512 values
0x4E00 ... 0x4FFF683D512 values
0x5000 ... 0x51FF6732512 values
0x5200 ... 0x53FF6633512 values
0x5400 ... 0x55FF6530512 values
0x5600 ... 0x57FF6431512 values
0x5800 ... 0x59FF6336512 values
0x5A00 ... 0x5BFF6237512 values
0x5C00 ... 0x5DFF6134512 values
0x5E00 ... 0x5FFF6035512 values
0x6000 ... 0x60FF5F0A256 values
0x6100 ... 0x61FF5E0B256 values
0x6200 ... 0x62FF5D08256 values
0x6300 ... 0x63FF5C09256 values
0x6400 ... 0x64FF5B0E256 values
0x6500 ... 0x65FF5A0F256 values
0x6600 ... 0x66FF590C256 values
0x6700 ... 0x67FF580D256 values
0x6800 ... 0x68FF5702256 values
0x6900 ... 0x69FF5603256 values
0x6A00 ... 0x6AFF5500256 values
0x6B00 ... 0x6BFF5401256 values
0x6C00 ... 0x6CFF5306256 values
0x6D00 ... 0x6DFF5207256 values
0x6E00 ... 0x6EFF5104256 values
0x6F00 ... 0x6FFF5005256 values
0x7000 ... 0x707F4F1A128 values
0x7080 ... 0x70FF4E1B128 values
0x7100 ... 0x717F4D18128 values
0x7180 ... 0x71FF4C19128 values
0x7200 ... 0x727F4B1E128 values
0x7280 ... 0x72FF4A1F128 values
0x7300 ... 0x737F491C128 values
0x7380 ... 0x73FF481D128 values
0x7400 ... 0x747F4712128 values
0x7480 ... 0x74FF4613128 values
0x7500 ... 0x757F4510128 values
0x7580 ... 0x75FF4411128 values
0x7600 ... 0x767F4316128 values
0x7680 ... 0x76FF4217128 values
0x7700 ... 0x777F4114128 values
0x7780 ... 0x77FF4015128 values
0x7800 ... 0x783F3F6A64 values
0x7840 ... 0x787F3E6B64 values
0x7880 ... 0x78BF3D6864 values
0x78C0 ... 0x78FF3C6964 values
0x7900 ... 0x793F3B6E64 values
0x7940 ... 0x797F3A6F64 values
0x7980 ... 0x79BF396C64 values
0x79C0 ... 0x79FF386D64 values
0x7A00 ... 0x7A3F376264 values
0x7A40 ... 0x7A7F366364 values
0x7A80 ... 0x7ABF356064 values
0x7AC0 ... 0x7AFF346164 values
0x7B00 ... 0x7B3F336664 values
0x7B40 ... 0x7B7F326764 values
0x7B80 ... 0x7BBF316464 values
0x7BC0 ... 0x7BFF306564 values
0x7C00 ... 0x7C1F2F7A32 values
0x7C20 ... 0x7C3F2E7B32 values
0x7C40 ... 0x7C5F2D7832 values
0x7C60 ... 0x7C7F2C7932 values
0x7C80 ... 0x7C9F2B7E32 values
0x7CA0 ... 0x7CBF2A7F32 values
0x7CC0 ... 0x7CDF297C32 values
0x7CE0 ... 0x7CFF287D32 values
0x7D00 ... 0x7D1F277232 values
0x7D20 ... 0x7D3F267332 values
0x7D40 ... 0x7D5F257032 values
0x7D60 ... 0x7D7F247132 values
0x7D80 ... 0x7D9F237632 values
0x7DA0 ... 0x7DBF227732 values
0x7DC0 ... 0x7DDF217432 values
0x7DE0 ... 0x7DFF207532 values
0x7E00 ... 0x7E0F1F4A16 values
0x7E10 ... 0x7E1F1E4B16 values
0x7E20 ... 0x7E2F1D4816 values
0x7E30 ... 0x7E3F1C4916 values
0x7E40 ... 0x7E4F1B4E16 values
0x7E50 ... 0x7E5F1A4F16 values
0x7E60 ... 0x7E6F194C16 values
0x7E70 ... 0x7E7F184D16 values
0x7E80 ... 0x7E8F174216 values
0x7E90 ... 0x7E9F164316 values
0x7EA0 ... 0x7EAF154016 values
0x7EB0 ... 0x7EBF144116 values
0x7EC0 ... 0x7ECF134616 values
0x7ED0 ... 0x7EDF124716 values
0x7EE0 ... 0x7EEF114416 values
0x7EF0 ... 0x7EFF104516 values
0x7F00 ... 0x7F0F0F5A16 values
0x7F10 ... 0x7F1F0E5B16 values
0x7F20 ... 0x7F2F0D5816 values
0x7F30 ... 0x7F3F0C5916 values
0x7F40 ... 0x7F4F0B5E16 values
0x7F50 ... 0x7F5F0A5F16 values
0x7F60 ... 0x7F6F095C16 values
0x7F70 ... 0x7F7F085D16 values
0x7F80 ... 0x7F8F075216 values
0x7F90 ... 0x7F9F065316 values
0x7FA0 ... 0x7FAF055016 values
0x7FB0 ... 0x7FBF045116 values
0x7FC0 ... 0x7FCF035616 values
0x7FD0 ... 0x7FDF025716 values
0x7FE0 ... 0x7FEF015416 values
0x7FF0 ... 0x7FFF005516 values
A-law encoding table
u16cA-lawRange size
0x8000 ... 0x800F80D516 values
0x8010 ... 0x801F81D416 values
0x8020 ... 0x802F82D716 values
0x8030 ... 0x803F83D616 values
0x8040 ... 0x804F84D116 values
0x8050 ... 0x805F85D016 values
0x8060 ... 0x806F86D316 values
0x8070 ... 0x807F87D216 values
0x8080 ... 0x808F88DD16 values
0x8090 ... 0x809F89DC16 values
0x80A0 ... 0x80AF8ADF16 values
0x80B0 ... 0x80BF8BDE16 values
0x80C0 ... 0x80CF8CD916 values
0x80D0 ... 0x80DF8DD816 values
0x80E0 ... 0x80EF8EDB16 values
0x80F0 ... 0x80FF8FDA16 values
0x8100 ... 0x810F90C516 values
0x8110 ... 0x811F91C416 values
0x8120 ... 0x812F92C716 values
0x8130 ... 0x813F93C616 values
0x8140 ... 0x814F94C116 values
0x8150 ... 0x815F95C016 values
0x8160 ... 0x816F96C316 values
0x8170 ... 0x817F97C216 values
0x8180 ... 0x818F98CD16 values
0x8190 ... 0x819F99CC16 values
0x81A0 ... 0x81AF9ACF16 values
0x81B0 ... 0x81BF9BCE16 values
0x81C0 ... 0x81CF9CC916 values
0x81D0 ... 0x81DF9DC816 values
0x81E0 ... 0x81EF9ECB16 values
0x81F0 ... 0x81FF9FCA16 values
0x8200 ... 0x821FA0F532 values
0x8220 ... 0x823FA1F432 values
0x8240 ... 0x825FA2F732 values
0x8260 ... 0x827FA3F632 values
0x8280 ... 0x829FA4F132 values
0x82A0 ... 0x82BFA5F032 values
0x82C0 ... 0x82DFA6F332 values
0x82E0 ... 0x82FFA7F232 values
0x8300 ... 0x831FA8FD32 values
0x8320 ... 0x833FA9FC32 values
0x8340 ... 0x835FAAFF32 values
0x8360 ... 0x837FABFE32 values
0x8380 ... 0x839FACF932 values
0x83A0 ... 0x83BFADF832 values
0x83C0 ... 0x83DFAEFB32 values
0x83E0 ... 0x83FFAFFA32 values
0x8400 ... 0x843FB0E564 values
0x8440 ... 0x847FB1E464 values
0x8480 ... 0x84BFB2E764 values
0x84C0 ... 0x84FFB3E664 values
0x8500 ... 0x853FB4E164 values
0x8540 ... 0x857FB5E064 values
0x8580 ... 0x85BFB6E364 values
0x85C0 ... 0x85FFB7E264 values
0x8600 ... 0x863FB8ED64 values
0x8640 ... 0x867FB9EC64 values
0x8680 ... 0x86BFBAEF64 values
0x86C0 ... 0x86FFBBEE64 values
0x8700 ... 0x873FBCE964 values
0x8740 ... 0x877FBDE864 values
0x8780 ... 0x87BFBEEB64 values
0x87C0 ... 0x87FFBFEA64 values
0x8800 ... 0x887FC095128 values
0x8880 ... 0x88FFC194128 values
0x8900 ... 0x897FC297128 values
0x8980 ... 0x89FFC396128 values
0x8A00 ... 0x8A7FC491128 values
0x8A80 ... 0x8AFFC590128 values
0x8B00 ... 0x8B7FC693128 values
0x8B80 ... 0x8BFFC792128 values
0x8C00 ... 0x8C7FC89D128 values
0x8C80 ... 0x8CFFC99C128 values
0x8D00 ... 0x8D7FCA9F128 values
0x8D80 ... 0x8DFFCB9E128 values
0x8E00 ... 0x8E7FCC99128 values
0x8E80 ... 0x8EFFCD98128 values
0x8F00 ... 0x8F7FCE9B128 values
0x8F80 ... 0x8FFFCF9A128 values
0x9000 ... 0x90FFD085256 values
0x9100 ... 0x91FFD184256 values
0x9200 ... 0x92FFD287256 values
0x9300 ... 0x93FFD386256 values
0x9400 ... 0x94FFD481256 values
0x9500 ... 0x95FFD580256 values
0x9600 ... 0x96FFD683256 values
0x9700 ... 0x97FFD782256 values
0x9800 ... 0x98FFD88D256 values
0x9900 ... 0x99FFD98C256 values
0x9A00 ... 0x9AFFDA8F256 values
0x9B00 ... 0x9BFFDB8E256 values
0x9C00 ... 0x9CFFDC89256 values
0x9D00 ... 0x9DFFDD88256 values
0x9E00 ... 0x9EFFDE8B256 values
0x9F00 ... 0x9FFFDF8A256 values
0xA000 ... 0xA1FFE0B5512 values
0xA200 ... 0xA3FFE1B4512 values
0xA400 ... 0xA5FFE2B7512 values
0xA600 ... 0xA7FFE3B6512 values
0xA800 ... 0xA9FFE4B1512 values
0xAA00 ... 0xABFFE5B0512 values
0xAC00 ... 0xADFFE6B3512 values
0xAE00 ... 0xAFFFE7B2512 values
0xB000 ... 0xB1FFE8BD512 values
0xB200 ... 0xB3FFE9BC512 values
0xB400 ... 0xB5FFEABF512 values
0xB600 ... 0xB7FFEBBE512 values
0xB800 ... 0xB9FFECB9512 values
0xBA00 ... 0xBBFFEDB8512 values
0xBC00 ... 0xBDFFEEBB512 values
0xBE00 ... 0xBFFFEFBA512 values
0xC000 ... 0xC3FFF0A51024 values
0xC400 ... 0xC7FFF1A41024 values
0xC800 ... 0xCBFFF2A71024 values
0xCC00 ... 0xCFFFF3A61024 values
0xD000 ... 0xD3FFF4A11024 values
0xD400 ... 0xD7FFF5A01024 values
0xD800 ... 0xDBFFF6A31024 values
0xDC00 ... 0xDFFFF7A21024 values
0xE000 ... 0xE3FFF8AD1024 values
0xE400 ... 0xE7FFF9AC1024 values
0xE800 ... 0xEBFFFAAF1024 values
0xEC00 ... 0xEFFFFBAE1024 values
0xF000 ... 0xF3FFFCA91024 values
0xF400 ... 0xF7FFFDA81024 values
0xF800 ... 0xFBFFFEAB1024 values
0xFC00 ... 0xFFFFFFAA1024 values

What do you think about such a table? --RokerHRO (talk) 21:53, 16 April 2010 (UTC)

I think such a table makes the article longish and hard to read. If a table is to be included perhaps in 8×8 form of somekind for compactness. Also might useful to contrast with u-law values for same codepoint. In general I think a more graphical / illustrative approach showing the quantized code points vs continuous 16 bit would be more educational than a full table. Jaxbax7 (talk) 21:15, 7 January 2014 (UTC)

and what would be the decoding table?!

Origin of μ and A in names?

[edit]

I think it would be interesting for readers to learn about the origin / history of the µ and A in the terms µ-law and A-law. Do we have any WP:RS for this? --Matthiaspaul (talk) 18:02, 8 June 2021 (UTC)Reply

Origin point for A/mu Law lines on chart questionable?

[edit]

As I also just commented on the Mu-Law talk page - shouldn't the blue and red lines also start at 0:0, same as the green one, as these are all digital systems? An analogue setup doing the same may produce over-unity signals, but in this context either anything over 0dB will get clipped, or the whole line needs to be shifted to the right (on this chart) to normalise 0dB "encoded" with 0dB input/output and avoid that? 92.12.87.15 (talk) 18:04, 31 October 2023 (UTC)Reply

Overall quality of sound samples don't match

[edit]

And again, did just point this out on Mu-Law as well - the general quality of the "original" sample is basically CD grade, but the "encoded" one is phone grade. That decimation is not part of the standard itself and makes the encoding seem much lower quality than it actually is... I expect whoever prepared the samples didn't appreciate that point and used a simple generic converter which does all the parts in one (companding to 8 bits, reducing sample rate, merging channels etc).

Either a new "encoded" version needs to be prepared from the original with the only change being from "14" bit PCM (actually 16, but not hard to flatten the two LSBs by normalising to 25% then back to 100%) to 8-bit A-law, or the "original" needs to be decimated in the same way as the encoded one except for it remaining full precision PCM, so the actual effect of the encoding on noise and dynamics can be demonstrated. (I can't do it due to a lack of WP account, else I'd have just done it - it's not complicated to export something suitable from e.g. Audacity)

...and as a further point I *didn't* put on mu-law - perhaps a third sample could be provided as a comparison, that being straight 8-bit PCM, to show how the perceptual quality of the companded version sits somewhere between that and the original? (Maybe a fourth ADPCM or GSM one too to show an alternative method of crushing the data even further, if that's not excessive - it's not like they take up much page space or even a lot of data on the server... though I don't know of a GSM encoder that goes above 16kHz so that'd demand everything being reduced to that level as a maximum...) 92.12.87.15 (talk) 18:12, 31 October 2023 (UTC)Reply

@Morn: These audio examples here and at µ-law are useless and misleading in their current form. The only noticeable difference between the original and the one labelled A-law (resp. µ-law) is that the latter is low-pass filtered.
This is, of course, an antialiasing filter used when downsampling to 8kHz, but if we want to show the effect of the companding itself (as the captions seem to imply), then the sample encoding should be the only difference between them and both should have the same sampling rate. However, this wouldn't be very illustrative either, because the difference between 8-bit A-/µ-law and the original 16-bit linear PCM would not be audible to most readers (if it's perceptible at all with speech). I think the IP above has a good idea re including 8-bit linear PCM for comparison, as this would necessarily have raised quantization noise to easily audible levels while A-/µ-law would keep it much lower at the same bitrate. – MwGamera (talk) 16:03, 25 November 2023 (UTC)Reply
I modified the comparison to include A-/µ-law-companded samples (expanded without dithering back to 16-bit with 13/14 significant bits, respectively, because Commons doesn't allow A- or µ-law encoded WAVs) and with 8- and 16-bit linear PCM for comparison, all sampled at 8 kHz. I used the original audio that Morn provided, but perhaps it might be a good idea to have some jingle or something else besides speech to make the differences stand out more. – MwGamera (talk) 00:59, 27 November 2023 (UTC)Reply

A-law as defined in G.711

[edit]

Article neglects to mention that A-law as defined in G.711 is not actually defined in terms of the continuous equation but a piecewise linear approximation of it. This is mentioned in the readme of the linked C code as well as in various application notes, e.g. https://www.nxp.com/docs/en/application-note/ANE408.pdf: "Mathematically speaking, MU & A-laws are piece-wise linear approximations of the above equations." 2601:644:8100:168D:CDF5:858A:C61:502A (talk) 00:53, 26 November 2024 (UTC)Reply

Value of A

[edit]

The constant A appears to come from nowhere. In fact, it is chosen precisely so the encoding increases by 16 if you double the input, making it easy to encode and decode. To be precise, A is the solution to the equation A(1+ln(A))=16, giving 87,5565596972731855380546823552 if you want a few more digits :-) Jurjen B (talk) 14:13, 6 June 2026 (UTC)Reply