Talk:mu-law algorithm

Latest comment: 1 year ago by MwGamera in topic Worst possible choice for speech samples

Talk

edit

This article should be called "μ-law algorithm" with a lower-case μ. Unfortunately, the software currently prevents this, capitalizing the mu. Capital mu looks just like "M", which just looks wrong. -- Karada 23:19, 29 October 2005 (UTC)Reply

I changed it to "Mu-law algorithm", because a capital mu is evil. Not only does it look dumb, it isn't obvious to most people that it's a mu and not the Latin letter M. And nobody calls it M-law. - furrykef (Talk at me) 14:26, 8 April 2006 (UTC)Reply

Graph/legend and text inconsistency

edit

"Comparison with A-law: A special feature ... near zero sound pressure...": this is not expected from the analytical expression of F, and not visible on the graph (does it occur at a level below -80 dB ? In this case, a proper scaling of the axis should display the difference between A and Mu laws).

In addition, the green line on the graph is not "A-law", but "No companding"... --Dgcrete 12:27, 22 August 2006 (UTC)Reply

I fixed the graph. Regarding the "special feature near zero" - this statement is false (assuming there is no mistake in the formulae). Near zero, the mu-law and A-law formulae differ only by a constant multiplier. This is because as x goes to zero, ln(1+x) becomes the same as x, hence the top halves of the Mu-law and A-law equations become the same. The same is true for the for the quantized versions of the equations.
I will remove the "special feature near zero" comment.
I've also added quantized points to the graph
Ozhiker 22:18, 22 August 2006 (UTC)Reply

Table of 14 bit linear values incorrect?

edit

I think the table of u-law to 14 bit linear is slightly incorrect. e.g. the first value should be -8031 rather than -8159.

-8159 is the maximum negative input to an encoder, which encodes to 0, but 0 should decode to -8031 (which is the centre of the range of values that encode to 0)

I think the 14 bit values should just be the given 16 bit values divided by 4. (The 16 bit values appear to be correct) TimMorley 16:34, 25 May 2007 (UTC)Reply

Odd reference

edit

One of the two references is from Wikipedia itself. That seems a bit sketchy...? 24.4.102.10 11:28, 23 September 2007 (UTC)Reply

Who is right?

edit

The table in this article differs from the code given in : Both 0x7F and 0xFF decodes to 0. But the encoder in the article encodes 0 to 0xFF and -1 to 0x7F. --RokerHRO (talk) 08:11, 1 March 2010 (UTC)Reply

Encoding table

edit

I created an encoding table from "unsigned linear 16 bit" values into µ-law 8 bit values using some self-written programs for data generating and pretty printing and SoX for the µ-law encoding. As you can see the octet 0x7F does not apper in this µ-law encoding table.

µ-law encoding table
u16µ-lawRange size
0x0000 ... 0x0487001160 values
0x0488 ... 0x0887011024 values
0x0888 ... 0x0C87021024 values
0x0C88 ... 0x1087031024 values
0x1088 ... 0x1487041024 values
0x1488 ... 0x1887051024 values
0x1888 ... 0x1C87061024 values
0x1C88 ... 0x2087071024 values
0x2088 ... 0x2487081024 values
0x2488 ... 0x2887091024 values
0x2888 ... 0x2C870A1024 values
0x2C88 ... 0x30870B1024 values
0x3088 ... 0x34870C1024 values
0x3488 ... 0x38870D1024 values
0x3888 ... 0x3C870E1024 values
0x3C88 ... 0x40870F1024 values
0x4088 ... 0x428710512 values
0x4288 ... 0x448711512 values
0x4488 ... 0x468712512 values
0x4688 ... 0x488713512 values
0x4888 ... 0x4A8714512 values
0x4A88 ... 0x4C8715512 values
0x4C88 ... 0x4E8716512 values
0x4E88 ... 0x508717512 values
0x5088 ... 0x528718512 values
0x5288 ... 0x548719512 values
0x5488 ... 0x56871A512 values
0x5688 ... 0x58871B512 values
0x5888 ... 0x5A871C512 values
0x5A88 ... 0x5C871D512 values
0x5C88 ... 0x5E871E512 values
0x5E88 ... 0x60871F512 values
0x6088 ... 0x618720256 values
0x6188 ... 0x628721256 values
0x6288 ... 0x638722256 values
0x6388 ... 0x648723256 values
0x6488 ... 0x658724256 values
0x6588 ... 0x668725256 values
0x6688 ... 0x678726256 values
0x6788 ... 0x688727256 values
0x6888 ... 0x698728256 values
0x6988 ... 0x6A8729256 values
0x6A88 ... 0x6B872A256 values
0x6B88 ... 0x6C872B256 values
0x6C88 ... 0x6D872C256 values
0x6D88 ... 0x6E872D256 values
0x6E88 ... 0x6F872E256 values
0x6F88 ... 0x70872F256 values
0x7088 ... 0x710730128 values
0x7108 ... 0x718731128 values
0x7188 ... 0x720732128 values
0x7208 ... 0x728733128 values
0x7288 ... 0x730734128 values
0x7308 ... 0x738735128 values
0x7388 ... 0x740736128 values
0x7408 ... 0x748737128 values
0x7488 ... 0x750738128 values
0x7508 ... 0x758739128 values
0x7588 ... 0x76073A128 values
0x7608 ... 0x76873B128 values
0x7688 ... 0x77073C128 values
0x7708 ... 0x77873D128 values
0x7788 ... 0x78073E128 values
0x7808 ... 0x78873F128 values
0x7888 ... 0x78C74064 values
0x78C8 ... 0x79074164 values
0x7908 ... 0x79474264 values
0x7948 ... 0x79874364 values
0x7988 ... 0x79C74464 values
0x79C8 ... 0x7A074564 values
0x7A08 ... 0x7A474664 values
0x7A48 ... 0x7A874764 values
0x7A88 ... 0x7AC74864 values
0x7AC8 ... 0x7B074964 values
0x7B08 ... 0x7B474A64 values
0x7B48 ... 0x7B874B64 values
0x7B88 ... 0x7BC74C64 values
0x7BC8 ... 0x7C074D64 values
0x7C08 ... 0x7C474E64 values
0x7C48 ... 0x7C874F64 values
0x7C88 ... 0x7CA75032 values
0x7CA8 ... 0x7CC75132 values
0x7CC8 ... 0x7CE75232 values
0x7CE8 ... 0x7D075332 values
0x7D08 ... 0x7D275432 values
0x7D28 ... 0x7D475532 values
0x7D48 ... 0x7D675632 values
0x7D68 ... 0x7D875732 values
0x7D88 ... 0x7DA75832 values
0x7DA8 ... 0x7DC75932 values
0x7DC8 ... 0x7DE75A32 values
0x7DE8 ... 0x7E075B32 values
0x7E08 ... 0x7E275C32 values
0x7E28 ... 0x7E475D32 values
0x7E48 ... 0x7E675E32 values
0x7E68 ... 0x7E875F32 values
0x7E88 ... 0x7E976016 values
0x7E98 ... 0x7EA76116 values
0x7EA8 ... 0x7EB76216 values
0x7EB8 ... 0x7EC76316 values
0x7EC8 ... 0x7ED76416 values
0x7ED8 ... 0x7EE76516 values
0x7EE8 ... 0x7EF76616 values
0x7EF8 ... 0x7F076716 values
0x7F08 ... 0x7F176816 values
0x7F18 ... 0x7F276916 values
0x7F28 ... 0x7F376A16 values
0x7F38 ... 0x7F476B16 values
0x7F48 ... 0x7F576C16 values
0x7F58 ... 0x7F676D16 values
0x7F68 ... 0x7F776E16 values
0x7F78 ... 0x7F876F16 values
0x7F88 ... 0x7F8F708 values
0x7F90 ... 0x7F97718 values
0x7F98 ... 0x7F9F728 values
0x7FA0 ... 0x7FA7738 values
0x7FA8 ... 0x7FAF748 values
0x7FB0 ... 0x7FB7758 values
0x7FB8 ... 0x7FBF768 values
0x7FC0 ... 0x7FC7778 values
0x7FC8 ... 0x7FCF788 values
0x7FD0 ... 0x7FD7798 values
0x7FD8 ... 0x7FDF7A8 values
0x7FE0 ... 0x7FE77B8 values
0x7FE8 ... 0x7FEF7C8 values
0x7FF0 ... 0x7FF77D8 values
0x7FF8 ... 0x7FFF7E8 values
µ-law encoding table
u16µ-lawRange size
0x8000 ... 0x8003FF4 values
0x8004 ... 0x800BFE8 values
0x800C ... 0x8013FD8 values
0x8014 ... 0x801BFC8 values
0x801C ... 0x8023FB8 values
0x8024 ... 0x802BFA8 values
0x802C ... 0x8033F98 values
0x8034 ... 0x803BF88 values
0x803C ... 0x8043F78 values
0x8044 ... 0x804BF68 values
0x804C ... 0x8053F58 values
0x8054 ... 0x805BF48 values
0x805C ... 0x8063F38 values
0x8064 ... 0x806BF28 values
0x806C ... 0x8073F18 values
0x8074 ... 0x807BF08 values
0x807C ... 0x808BEF16 values
0x808C ... 0x809BEE16 values
0x809C ... 0x80ABED16 values
0x80AC ... 0x80BBEC16 values
0x80BC ... 0x80CBEB16 values
0x80CC ... 0x80DBEA16 values
0x80DC ... 0x80EBE916 values
0x80EC ... 0x80FBE816 values
0x80FC ... 0x810BE716 values
0x810C ... 0x811BE616 values
0x811C ... 0x812BE516 values
0x812C ... 0x813BE416 values
0x813C ... 0x814BE316 values
0x814C ... 0x815BE216 values
0x815C ... 0x816BE116 values
0x816C ... 0x817BE016 values
0x817C ... 0x819BDF32 values
0x819C ... 0x81BBDE32 values
0x81BC ... 0x81DBDD32 values
0x81DC ... 0x81FBDC32 values
0x81FC ... 0x821BDB32 values
0x821C ... 0x823BDA32 values
0x823C ... 0x825BD932 values
0x825C ... 0x827BD832 values
0x827C ... 0x829BD732 values
0x829C ... 0x82BBD632 values
0x82BC ... 0x82DBD532 values
0x82DC ... 0x82FBD432 values
0x82FC ... 0x831BD332 values
0x831C ... 0x833BD232 values
0x833C ... 0x835BD132 values
0x835C ... 0x837BD032 values
0x837C ... 0x83BBCF64 values
0x83BC ... 0x83FBCE64 values
0x83FC ... 0x843BCD64 values
0x843C ... 0x847BCC64 values
0x847C ... 0x84BBCB64 values
0x84BC ... 0x84FBCA64 values
0x84FC ... 0x853BC964 values
0x853C ... 0x857BC864 values
0x857C ... 0x85BBC764 values
0x85BC ... 0x85FBC664 values
0x85FC ... 0x863BC564 values
0x863C ... 0x867BC464 values
0x867C ... 0x86BBC364 values
0x86BC ... 0x86FBC264 values
0x86FC ... 0x873BC164 values
0x873C ... 0x877BC064 values
0x877C ... 0x87FBBF128 values
0x87FC ... 0x887BBE128 values
0x887C ... 0x88FBBD128 values
0x88FC ... 0x897BBC128 values
0x897C ... 0x89FBBB128 values
0x89FC ... 0x8A7BBA128 values
0x8A7C ... 0x8AFBB9128 values
0x8AFC ... 0x8B7BB8128 values
0x8B7C ... 0x8BFBB7128 values
0x8BFC ... 0x8C7BB6128 values
0x8C7C ... 0x8CFBB5128 values
0x8CFC ... 0x8D7BB4128 values
0x8D7C ... 0x8DFBB3128 values
0x8DFC ... 0x8E7BB2128 values
0x8E7C ... 0x8EFBB1128 values
0x8EFC ... 0x8F7BB0128 values
0x8F7C ... 0x907BAF256 values
0x907C ... 0x917BAE256 values
0x917C ... 0x927BAD256 values
0x927C ... 0x937BAC256 values
0x937C ... 0x947BAB256 values
0x947C ... 0x957BAA256 values
0x957C ... 0x967BA9256 values
0x967C ... 0x977BA8256 values
0x977C ... 0x987BA7256 values
0x987C ... 0x997BA6256 values
0x997C ... 0x9A7BA5256 values
0x9A7C ... 0x9B7BA4256 values
0x9B7C ... 0x9C7BA3256 values
0x9C7C ... 0x9D7BA2256 values
0x9D7C ... 0x9E7BA1256 values
0x9E7C ... 0x9F7BA0256 values
0x9F7C ... 0xA17B9F512 values
0xA17C ... 0xA37B9E512 values
0xA37C ... 0xA57B9D512 values
0xA57C ... 0xA77B9C512 values
0xA77C ... 0xA97B9B512 values
0xA97C ... 0xAB7B9A512 values
0xAB7C ... 0xAD7B99512 values
0xAD7C ... 0xAF7B98512 values
0xAF7C ... 0xB17B97512 values
0xB17C ... 0xB37B96512 values
0xB37C ... 0xB57B95512 values
0xB57C ... 0xB77B94512 values
0xB77C ... 0xB97B93512 values
0xB97C ... 0xBB7B92512 values
0xBB7C ... 0xBD7B91512 values
0xBD7C ... 0xBF7B90512 values
0xBF7C ... 0xC37B8F1024 values
0xC37C ... 0xC77B8E1024 values
0xC77C ... 0xCB7B8D1024 values
0xCB7C ... 0xCF7B8C1024 values
0xCF7C ... 0xD37B8B1024 values
0xD37C ... 0xD77B8A1024 values
0xD77C ... 0xDB7B891024 values
0xDB7C ... 0xDF7B881024 values
0xDF7C ... 0xE37B871024 values
0xE37C ... 0xE77B861024 values
0xE77C ... 0xEB7B851024 values
0xEB7C ... 0xEF7B841024 values
0xEF7C ... 0xF37B831024 values
0xF37C ... 0xF77B821024 values
0xF77C ... 0xFB7B811024 values
0xFB7C ... 0xFFFF801156 values

The table differs slightly from the more compact one in the article. Which is correct? --RokerHRO (talk) 22:05, 16 April 2010 (UTC)Reply

What is the rationale behind the choice μ = 255?

edit

Why is the value of μ chosen to be 255? The article seems to suggest that this is because 255 = 2n - 1, where n is the number of bits used to store the encoding, but I see no reason for this.

I guess that evidently, choosing μ = 255 works well, but to me, this seems like an ad hoc choice rather than a choice that has anything to do with the number of bits used. I think it seems more reasonable that the encoding (i.e., F(x)) should be independent of the number of bits used to store the encoding and rather be based on the maximum sound pressure you want to support and the sensitivity of the human auditory system as a function of the sound pressure (such that the encoding has more densely packed quantization levels for sound pressures where the auditory system is more sensitive to small changes in the sound pressure).

I can think of two reasons that led to the choice μ = 255:

  1. The expressions for the encoding and decoding can be evaluated efficiently when μ = 255 — especially, ln(1 + μ) = ln(1 + 255) = 8 log2(1 + μ) = log2(1 + 255) = 8, so the division in the encoding can be preformed very efficiently by just preforming an arithmetic shift (presuming that the base of the logarithms is changed from e to 2) — however, this is true for any μ = 22m - 1, where m is a non-negatve integer
  2. Choosing μ = 255 happens to give a reasonably good sound quality for all sound pressures that it should be possible represent

However, I see no connection between μ and the number of bits used to store the encoding, which the article suggests that there is.

So, is there such a connection? Or is the value 255 an ad hoc value chosen mostly for the reasons I listed? Or in other words, what is the rationale behind choosing μ = 255? —Kri (talk) 22:50, 17 June 2018 (UTC); edited 06:32, 21 June 2018 (UTC)Reply

Isn't that just to get the resulting 8-bit value of the input of the function? In other words μ specifies the maximum value of the output (minimum being 0), with the input's range being -1 to 1. —DIYeditor (talk) 01:55, 18 June 2018 (UTC)Reply
No, it's not. The output of F is still in the range -1 to +1, no matter what value you choose for μ. —Kri (talk) 19:27, 18 June 2018 (UTC)Reply
I tried to look through some technical papers and had trouble finding a straight answer for this. I think maybe part of it is as you say that 255 gives approximately the desired curve. As for the main reason: does the value 255 make the segments as defined in the g.711 recommendation (tables 2a and 2b) turn out as approximately powers of two intervals (less ~31)? This was a good call on your part, we need to clarify the article and address the part implying this is directly related to the 8-bit value. We need a RS that directly addresses this choice. —DIYeditor (talk) 01:05, 19 June 2018 (UTC)Reply
I also sifted through the G.711 recommendation but didn’t find any explanation for why μ = 255 is used.
What is an RS? —Kri (talk) 07:10, 21 June 2018 (UTC)Reply
WP:RS. —DIYeditor (talk) 19:28, 21 June 2018 (UTC)Reply
So is it okay if I remove the parenthesis "(8 bits)" since the choice μ = 255 and the number of bits used don't really seem to be related? —Kri (talk) 07:32, 2 July 2018 (UTC)Reply
Yes I agree with that. Does not appear to be directly related, it was original research by someone. —DIYeditor (talk) 08:30, 2 July 2018 (UTC)Reply
Done. —Kri (talk) 14:13, 5 July 2018 (UTC)Reply

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:01, 8 June 2021 (UTC)Reply

Comparison with A-law

edit

The "Comparison with A-law" section states that "The μ-law algorithm provides a slightly larger dynamic range than the A-law at the cost of worse proportional distortions for small signals." I think this may be backwards -- that is, A-law provides larger dynamic range and worse small-signal distortion than μ-law. The same (possibly erroneous) statement is in the A-law article. --99.121.214.126 (talk) 02:41, 18 December 2021 (UTC)Reply

x-Axis of comparison plot confusingly labeled "Linear" but actually *logarithmic* (dBm0)

edit

I'm looking at the comparison chart that is in both this μ-law page and the A-law page:


While it is an otherwise excellent chart, I have a frustration with the creator's (@Ozhiker) word choice of "Linear" in the x-Axis label, because really the x-axis is a *log* scale (dBm0 is a logarithmic unit). Hence the "No companding" graph is a straight line. Maybe the creator was trying to express something else with "Linear" (or am I misunderstanding something), but I think "Linear" just confuses readers. Better readability would be simply "Input Signal (dBm0)". It seems the chart was made with gnuplot and has instructions, so I could easily edit it or the svg if the creator is not around. But I want to make sure I'm not misunderstanding. Em3rgent0rdr (talk) 23:18, 26 June 2023 (UTC)Reply

I agree, "Input Signal (dBm0)" would be a better label. Linear in the current label likely refers to the fact that compression is a non-linear process so the input in that sense is linear and the output non-linear. ~Kvng (talk) 12:27, 29 June 2023 (UTC)Reply
fixed. Em3rgent0rdr (talk) 19:46, 29 June 2023 (UTC)Reply
Additional problem: The red (and blue?) line(s) seem(s) to extend beyond 0dB, up to maybe +2 or +3dB? That might be fine for an analogue amplification system or recording to tape, perhaps (like using dolby companding to extend the effective dynamic range of audio cassette), but it's not possible in the digital domain. 0dB is the maximum possible representable signal strength, both for input and output. Even if the encoding means you end up with internally calculated values exceeding this, wouldn't they either be clipped to 0dB, or the entire output scale normalised to shift the maximum output to be such (and all quieter values moving down a little in kind)?  Preceding unsigned comment added by 92.12.87.15 (talk) 17:53, 31 October 2023 (UTC)Reply

Audio sample quality mismatch

edit

The two samples given for "original" and "encoded" are so far apart in overall quality that it's impossible to make a judgement of the effect on the sound caused by the A-law encoding. The "encoded" version seems to be recorded at a much lower sample rate / frequency for a start, which compromises the apparent quality much more than the companding, and isn't an inherent effect of the codec either. Possibly somebody fed a CD quality voice synth output into something that encodes into Phone quality mu-law, without considering that it also reduces the sample rate to about 1/6th as part of the process?

Either the "encoded" version needs to be remade with all other aspects being the same as the original one, which isn't hard to achieve via the export / save menu options of any half decent audio processing program (and would sound somewhere between the original and a plain 8-bit PCM conversion), or the "original" needs to be preprocessed and presented in a state otherwise matching the current encoded one, except for being 16 (or 14?) bit PCM not 8-bit mu-law encoded (so would also sound rather muffled etc).

...and if whoever's supplying the audio samples doesn't understand what any of that means or why it's a problem, they should refrain from any further uploads until they've studied up.

(I have no account so can't do that I'm afraid, otherwise I'd have already replaced it myself, it's been more than 25 years since the first time I experimentally messed around with format conversions of that type so it'd be a piece of cake) 92.12.87.15 (talk) 18:00, 31 October 2023 (UTC)Reply

Worst possible choice for speech samples

edit

The speech samples are machine-generated, seemingly with a model that produces audio optimized for phone (or alike) operations, and not a great speech model in terms of clarity, on top of that. How is one to compare quality of the original is already taking the impairments for granted?

I'll replace these. MüllerMarcus (talk) 16:03, 21 December 2024 (UTC)Reply

There goes my conversion effort in response to the previous comment above. I assumed the pre-existing original was good enough as the only perceptible difference should be the raised noise floor with 8-bit samples anyway. I intentionally lowered the sample rate of the original to make the effects of sample coding easier to compare. But yeah, Harvard sentences spoken by a real human are definitely much better source material. – MwGamera (talk) 20:29, 21 December 2024 (UTC)Reply