Talk:A-law algorithm
This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||
|
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)
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 u16 c A-law Range size 0x0000 ... 0x03FF 7F 2A 1024 values 0x0400 ... 0x07FF 7E 2B 1024 values 0x0800 ... 0x0BFF 7D 28 1024 values 0x0C00 ... 0x0FFF 7C 29 1024 values 0x1000 ... 0x13FF 7B 2E 1024 values 0x1400 ... 0x17FF 7A 2F 1024 values 0x1800 ... 0x1BFF 79 2C 1024 values 0x1C00 ... 0x1FFF 78 2D 1024 values 0x2000 ... 0x23FF 77 22 1024 values 0x2400 ... 0x27FF 76 23 1024 values 0x2800 ... 0x2BFF 75 20 1024 values 0x2C00 ... 0x2FFF 74 21 1024 values 0x3000 ... 0x33FF 73 26 1024 values 0x3400 ... 0x37FF 72 27 1024 values 0x3800 ... 0x3BFF 71 24 1024 values 0x3C00 ... 0x3FFF 70 25 1024 values 0x4000 ... 0x41FF 6F 3A 512 values 0x4200 ... 0x43FF 6E 3B 512 values 0x4400 ... 0x45FF 6D 38 512 values 0x4600 ... 0x47FF 6C 39 512 values 0x4800 ... 0x49FF 6B 3E 512 values 0x4A00 ... 0x4BFF 6A 3F 512 values 0x4C00 ... 0x4DFF 69 3C 512 values 0x4E00 ... 0x4FFF 68 3D 512 values 0x5000 ... 0x51FF 67 32 512 values 0x5200 ... 0x53FF 66 33 512 values 0x5400 ... 0x55FF 65 30 512 values 0x5600 ... 0x57FF 64 31 512 values 0x5800 ... 0x59FF 63 36 512 values 0x5A00 ... 0x5BFF 62 37 512 values 0x5C00 ... 0x5DFF 61 34 512 values 0x5E00 ... 0x5FFF 60 35 512 values 0x6000 ... 0x60FF 5F 0A 256 values 0x6100 ... 0x61FF 5E 0B 256 values 0x6200 ... 0x62FF 5D 08 256 values 0x6300 ... 0x63FF 5C 09 256 values 0x6400 ... 0x64FF 5B 0E 256 values 0x6500 ... 0x65FF 5A 0F 256 values 0x6600 ... 0x66FF 59 0C 256 values 0x6700 ... 0x67FF 58 0D 256 values 0x6800 ... 0x68FF 57 02 256 values 0x6900 ... 0x69FF 56 03 256 values 0x6A00 ... 0x6AFF 55 00 256 values 0x6B00 ... 0x6BFF 54 01 256 values 0x6C00 ... 0x6CFF 53 06 256 values 0x6D00 ... 0x6DFF 52 07 256 values 0x6E00 ... 0x6EFF 51 04 256 values 0x6F00 ... 0x6FFF 50 05 256 values 0x7000 ... 0x707F 4F 1A 128 values 0x7080 ... 0x70FF 4E 1B 128 values 0x7100 ... 0x717F 4D 18 128 values 0x7180 ... 0x71FF 4C 19 128 values 0x7200 ... 0x727F 4B 1E 128 values 0x7280 ... 0x72FF 4A 1F 128 values 0x7300 ... 0x737F 49 1C 128 values 0x7380 ... 0x73FF 48 1D 128 values 0x7400 ... 0x747F 47 12 128 values 0x7480 ... 0x74FF 46 13 128 values 0x7500 ... 0x757F 45 10 128 values 0x7580 ... 0x75FF 44 11 128 values 0x7600 ... 0x767F 43 16 128 values 0x7680 ... 0x76FF 42 17 128 values 0x7700 ... 0x777F 41 14 128 values 0x7780 ... 0x77FF 40 15 128 values 0x7800 ... 0x783F 3F 6A 64 values 0x7840 ... 0x787F 3E 6B 64 values 0x7880 ... 0x78BF 3D 68 64 values 0x78C0 ... 0x78FF 3C 69 64 values 0x7900 ... 0x793F 3B 6E 64 values 0x7940 ... 0x797F 3A 6F 64 values 0x7980 ... 0x79BF 39 6C 64 values 0x79C0 ... 0x79FF 38 6D 64 values 0x7A00 ... 0x7A3F 37 62 64 values 0x7A40 ... 0x7A7F 36 63 64 values 0x7A80 ... 0x7ABF 35 60 64 values 0x7AC0 ... 0x7AFF 34 61 64 values 0x7B00 ... 0x7B3F 33 66 64 values 0x7B40 ... 0x7B7F 32 67 64 values 0x7B80 ... 0x7BBF 31 64 64 values 0x7BC0 ... 0x7BFF 30 65 64 values 0x7C00 ... 0x7C1F 2F 7A 32 values 0x7C20 ... 0x7C3F 2E 7B 32 values 0x7C40 ... 0x7C5F 2D 78 32 values 0x7C60 ... 0x7C7F 2C 79 32 values 0x7C80 ... 0x7C9F 2B 7E 32 values 0x7CA0 ... 0x7CBF 2A 7F 32 values 0x7CC0 ... 0x7CDF 29 7C 32 values 0x7CE0 ... 0x7CFF 28 7D 32 values 0x7D00 ... 0x7D1F 27 72 32 values 0x7D20 ... 0x7D3F 26 73 32 values 0x7D40 ... 0x7D5F 25 70 32 values 0x7D60 ... 0x7D7F 24 71 32 values 0x7D80 ... 0x7D9F 23 76 32 values 0x7DA0 ... 0x7DBF 22 77 32 values 0x7DC0 ... 0x7DDF 21 74 32 values 0x7DE0 ... 0x7DFF 20 75 32 values 0x7E00 ... 0x7E0F 1F 4A 16 values 0x7E10 ... 0x7E1F 1E 4B 16 values 0x7E20 ... 0x7E2F 1D 48 16 values 0x7E30 ... 0x7E3F 1C 49 16 values 0x7E40 ... 0x7E4F 1B 4E 16 values 0x7E50 ... 0x7E5F 1A 4F 16 values 0x7E60 ... 0x7E6F 19 4C 16 values 0x7E70 ... 0x7E7F 18 4D 16 values 0x7E80 ... 0x7E8F 17 42 16 values 0x7E90 ... 0x7E9F 16 43 16 values 0x7EA0 ... 0x7EAF 15 40 16 values 0x7EB0 ... 0x7EBF 14 41 16 values 0x7EC0 ... 0x7ECF 13 46 16 values 0x7ED0 ... 0x7EDF 12 47 16 values 0x7EE0 ... 0x7EEF 11 44 16 values 0x7EF0 ... 0x7EFF 10 45 16 values 0x7F00 ... 0x7F0F 0F 5A 16 values 0x7F10 ... 0x7F1F 0E 5B 16 values 0x7F20 ... 0x7F2F 0D 58 16 values 0x7F30 ... 0x7F3F 0C 59 16 values 0x7F40 ... 0x7F4F 0B 5E 16 values 0x7F50 ... 0x7F5F 0A 5F 16 values 0x7F60 ... 0x7F6F 09 5C 16 values 0x7F70 ... 0x7F7F 08 5D 16 values 0x7F80 ... 0x7F8F 07 52 16 values 0x7F90 ... 0x7F9F 06 53 16 values 0x7FA0 ... 0x7FAF 05 50 16 values 0x7FB0 ... 0x7FBF 04 51 16 values 0x7FC0 ... 0x7FCF 03 56 16 values 0x7FD0 ... 0x7FDF 02 57 16 values 0x7FE0 ... 0x7FEF 01 54 16 values 0x7FF0 ... 0x7FFF 00 55 16 values
A-law encoding table u16 c A-law Range size 0x8000 ... 0x800F 80 D5 16 values 0x8010 ... 0x801F 81 D4 16 values 0x8020 ... 0x802F 82 D7 16 values 0x8030 ... 0x803F 83 D6 16 values 0x8040 ... 0x804F 84 D1 16 values 0x8050 ... 0x805F 85 D0 16 values 0x8060 ... 0x806F 86 D3 16 values 0x8070 ... 0x807F 87 D2 16 values 0x8080 ... 0x808F 88 DD 16 values 0x8090 ... 0x809F 89 DC 16 values 0x80A0 ... 0x80AF 8A DF 16 values 0x80B0 ... 0x80BF 8B DE 16 values 0x80C0 ... 0x80CF 8C D9 16 values 0x80D0 ... 0x80DF 8D D8 16 values 0x80E0 ... 0x80EF 8E DB 16 values 0x80F0 ... 0x80FF 8F DA 16 values 0x8100 ... 0x810F 90 C5 16 values 0x8110 ... 0x811F 91 C4 16 values 0x8120 ... 0x812F 92 C7 16 values 0x8130 ... 0x813F 93 C6 16 values 0x8140 ... 0x814F 94 C1 16 values 0x8150 ... 0x815F 95 C0 16 values 0x8160 ... 0x816F 96 C3 16 values 0x8170 ... 0x817F 97 C2 16 values 0x8180 ... 0x818F 98 CD 16 values 0x8190 ... 0x819F 99 CC 16 values 0x81A0 ... 0x81AF 9A CF 16 values 0x81B0 ... 0x81BF 9B CE 16 values 0x81C0 ... 0x81CF 9C C9 16 values 0x81D0 ... 0x81DF 9D C8 16 values 0x81E0 ... 0x81EF 9E CB 16 values 0x81F0 ... 0x81FF 9F CA 16 values 0x8200 ... 0x821F A0 F5 32 values 0x8220 ... 0x823F A1 F4 32 values 0x8240 ... 0x825F A2 F7 32 values 0x8260 ... 0x827F A3 F6 32 values 0x8280 ... 0x829F A4 F1 32 values 0x82A0 ... 0x82BF A5 F0 32 values 0x82C0 ... 0x82DF A6 F3 32 values 0x82E0 ... 0x82FF A7 F2 32 values 0x8300 ... 0x831F A8 FD 32 values 0x8320 ... 0x833F A9 FC 32 values 0x8340 ... 0x835F AA FF 32 values 0x8360 ... 0x837F AB FE 32 values 0x8380 ... 0x839F AC F9 32 values 0x83A0 ... 0x83BF AD F8 32 values 0x83C0 ... 0x83DF AE FB 32 values 0x83E0 ... 0x83FF AF FA 32 values 0x8400 ... 0x843F B0 E5 64 values 0x8440 ... 0x847F B1 E4 64 values 0x8480 ... 0x84BF B2 E7 64 values 0x84C0 ... 0x84FF B3 E6 64 values 0x8500 ... 0x853F B4 E1 64 values 0x8540 ... 0x857F B5 E0 64 values 0x8580 ... 0x85BF B6 E3 64 values 0x85C0 ... 0x85FF B7 E2 64 values 0x8600 ... 0x863F B8 ED 64 values 0x8640 ... 0x867F B9 EC 64 values 0x8680 ... 0x86BF BA EF 64 values 0x86C0 ... 0x86FF BB EE 64 values 0x8700 ... 0x873F BC E9 64 values 0x8740 ... 0x877F BD E8 64 values 0x8780 ... 0x87BF BE EB 64 values 0x87C0 ... 0x87FF BF EA 64 values 0x8800 ... 0x887F C0 95 128 values 0x8880 ... 0x88FF C1 94 128 values 0x8900 ... 0x897F C2 97 128 values 0x8980 ... 0x89FF C3 96 128 values 0x8A00 ... 0x8A7F C4 91 128 values 0x8A80 ... 0x8AFF C5 90 128 values 0x8B00 ... 0x8B7F C6 93 128 values 0x8B80 ... 0x8BFF C7 92 128 values 0x8C00 ... 0x8C7F C8 9D 128 values 0x8C80 ... 0x8CFF C9 9C 128 values 0x8D00 ... 0x8D7F CA 9F 128 values 0x8D80 ... 0x8DFF CB 9E 128 values 0x8E00 ... 0x8E7F CC 99 128 values 0x8E80 ... 0x8EFF CD 98 128 values 0x8F00 ... 0x8F7F CE 9B 128 values 0x8F80 ... 0x8FFF CF 9A 128 values 0x9000 ... 0x90FF D0 85 256 values 0x9100 ... 0x91FF D1 84 256 values 0x9200 ... 0x92FF D2 87 256 values 0x9300 ... 0x93FF D3 86 256 values 0x9400 ... 0x94FF D4 81 256 values 0x9500 ... 0x95FF D5 80 256 values 0x9600 ... 0x96FF D6 83 256 values 0x9700 ... 0x97FF D7 82 256 values 0x9800 ... 0x98FF D8 8D 256 values 0x9900 ... 0x99FF D9 8C 256 values 0x9A00 ... 0x9AFF DA 8F 256 values 0x9B00 ... 0x9BFF DB 8E 256 values 0x9C00 ... 0x9CFF DC 89 256 values 0x9D00 ... 0x9DFF DD 88 256 values 0x9E00 ... 0x9EFF DE 8B 256 values 0x9F00 ... 0x9FFF DF 8A 256 values 0xA000 ... 0xA1FF E0 B5 512 values 0xA200 ... 0xA3FF E1 B4 512 values 0xA400 ... 0xA5FF E2 B7 512 values 0xA600 ... 0xA7FF E3 B6 512 values 0xA800 ... 0xA9FF E4 B1 512 values 0xAA00 ... 0xABFF E5 B0 512 values 0xAC00 ... 0xADFF E6 B3 512 values 0xAE00 ... 0xAFFF E7 B2 512 values 0xB000 ... 0xB1FF E8 BD 512 values 0xB200 ... 0xB3FF E9 BC 512 values 0xB400 ... 0xB5FF EA BF 512 values 0xB600 ... 0xB7FF EB BE 512 values 0xB800 ... 0xB9FF EC B9 512 values 0xBA00 ... 0xBBFF ED B8 512 values 0xBC00 ... 0xBDFF EE BB 512 values 0xBE00 ... 0xBFFF EF BA 512 values 0xC000 ... 0xC3FF F0 A5 1024 values 0xC400 ... 0xC7FF F1 A4 1024 values 0xC800 ... 0xCBFF F2 A7 1024 values 0xCC00 ... 0xCFFF F3 A6 1024 values 0xD000 ... 0xD3FF F4 A1 1024 values 0xD400 ... 0xD7FF F5 A0 1024 values 0xD800 ... 0xDBFF F6 A3 1024 values 0xDC00 ... 0xDFFF F7 A2 1024 values 0xE000 ... 0xE3FF F8 AD 1024 values 0xE400 ... 0xE7FF F9 AC 1024 values 0xE800 ... 0xEBFF FA AF 1024 values 0xEC00 ... 0xEFFF FB AE 1024 values 0xF000 ... 0xF3FF FC A9 1024 values 0xF400 ... 0xF7FF FD A8 1024 values 0xF800 ... 0xFBFF FE AB 1024 values 0xFC00 ... 0xFFFF FF AA 1024 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)
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)
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)
- @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)
- 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)