HydrogenAudio

Lossy Audio Compression => MP3 => MP3 - Tech => Topic started by: pdq on 2012-08-28 20:20:17

Title: SNR of MP3
Post by: pdq on 2012-08-28 20:20:17
The SNR of an MP3 is around 25-30dB.

I don't know why you say that. The dynamic range of mp3 is obviously much greater than 30 dB.

I would be more inclined to describe mp3's deviation from the original as distortion rather than noise, because it is quite capable of rendering very quiet passages with very little added noise.
Title: SNR of MP3
Post by: itisljar on 2012-08-28 20:27:41
The SNR of an MP3 is around 25-30dB.  Does this mean that I only need to decode them to 6-bit PCM to capture all the details?
I am curious if anyone has ever done a detailed analysis of an LP's SNR in different frequency bands.


Huh?
That would mean that I couldn't be able to listen to classical music in mp3 format without some background hiss and noise always present.
Or did you mean something else?
Title: SNR of MP3
Post by: saratoga on 2012-08-28 20:29:23
The SNR of an MP3 is around 25-30dB.

I don't know why you say that. The dynamic range of mp3 is obviously much greater than 30 dB.


Dynamic range isn't the same as SNR.  However, I remember testing it at about 25dB for my tracks IIRC.

I would be more inclined to describe mp3's deviation from the original as distortion rather than noise, because it is quite capable of rendering very quiet passages with very little added noise.


Yes, I think his point is that SNR is not entirely meaningful if the noise isn't spectrally or temporally flat, or else it is correlated with the input signal.
Title: SNR of MP3
Post by: Arnold B. Krueger on 2012-08-29 12:41:03
The LP noise floor is rather high- maybe -70dB under very good conditions. 12-bit sampling (RMS noise floor of -72dB) would be sufficient for LP use as long as your levels are right (peak signal above -6dB). (12-bit sampling was used for DV but hasn't seen any other widespread use).


The SNR of an MP3 is around 25-30dB. 



In which alternative universe? At what ludicrously low bit rate?

SNR is a measurable quantity. I've measured it in high-bit rate MP3s. The exact number escapes me but I seem to recall some number north of 80 dB. It was so high that I questioned the use of bandwidth to maintain it.
Title: SNR of MP3
Post by: 2Bdecided on 2012-08-29 17:45:46
The SNR of an MP3 is around 25-30dB.


In which alternative universe? At what ludicrously low bit rate?

SNR is a measurable quantity. I've measured it in high-bit rate MP3s. The exact number escapes me but I seem to recall some number north of 80 dB. It was so high that I questioned the use of bandwidth to maintain it.
The dynamic range of mp3 is insane. The format itself has several hundred dB of dynamic range, and some 24-bit decoders give the expected 140dB.

But the "THD+N" (if you want to call it that) of mp3 with a complex test signal is often about 25dB below the test signal.

Cheers,
David.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-08-29 21:32:28
The SNR of an MP3 is around 25-30dB.  Does this mean that I only need to decode them to 6-bit PCM to capture all the details? I am curious if anyone has ever done a detailed analysis of an LP's SNR in different frequency bands.

You are right about the SNR of mp3 files: it is around 20 dB at 128 kbps and around 30 dB at 256 kbps. However the noise of mp3 is relative to the signal level, while the noise of PCM quantization is constant. So, mp3 files can indeed decode to a wide dynamic range, even beyond capabilities of the 16-bit PCM format. It all depends on the signal. In some sense, mp3 is similar to a 32-bit float format: its noise floor is ~150 dB below the signal level.

The noise floor of a LP record is approximately constant in time, but it is not white. So, the flat-dither 12-bit PCM format may not be sufficient to capture the LP signal.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-08-29 21:37:36
SNR is a measurable quantity. I've measured it in high-bit rate MP3s. The exact number escapes me but I seem to recall some number north of 80 dB. It was so high that I questioned the use of bandwidth to maintain it.

Arnie, you might have measured the lowest possible noise in mp3. It can indeed drop below –100 dB. But the coding distortion ("noise") of mp3 is proportional to the signal amplitude and complexity. For most typical music it is really only 20–30 dB below the signal level.
Title: SNR of MP3
Post by: Arnold B. Krueger on 2012-08-30 12:48:21
SNR is a measurable quantity. I've measured it in high-bit rate MP3s. The exact number escapes me but I seem to recall some number north of 80 dB. It was so high that I questioned the use of bandwidth to maintain it.

Arnie, you might have measured the lowest possible noise in mp3. It can indeed drop below –100 dB. But the coding distortion ("noise") of mp3 is proportional to the signal amplitude and complexity. For most typical music it is really only 20–30 dB below the signal level.


I took a closer look at the actual situation with music. I took a music file and added two narrow notches  about a decade apart using CEP 2.1's  FFT filter.  I found that the notches that I created were limited to about 60-65 dB which seems sufficient to give a reliable indication about the issue at hand, even though it is shy of the 80 dB I had been talking about.

This was a back-of-the envelope exploration, not a thesis project! ;-)

I encoded the notched file @ 320K with CEP 2.1's built-in encoder, converted back to .wav for analysis and found that while the bottoms of the notches lost some of their squareness, the depth of the notches did not change that much.  Still around 60 dB down. That seems to be more like my number.

I again encoded the file this time @ 128K with CEP 2.1's built-in encoder, converted back to .wav for analysis and found that the bottoms squareness were in the 20 dB range. That seems to be more like your number.

I think these rough results are representative, as far as they go.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-08-30 15:14:54
A simpler test is a subtraction test: subtract the mp3 waveform from the original waveform and measure the difference. Your test is probably valid too, but the notch should be narrow and you should rate the noise to the original signal level.
Title: SNR of MP3
Post by: Arnold B. Krueger on 2012-08-30 15:22:49
A simpler test is a subtraction test: subtract the mp3 waveform from the original waveform and measure the difference.


In general tests based on subtracting samples are prone to being misleading because there are too many influences that are only weakly relevant that affect their results.  Many have no or very limited bearing on audibility, such as a ten sample time shift which can cause a misleadingly large difference signal.

Quote
Your test is probably valid too, but the notch should be narrow and you should rate the noise to the original signal level.


Please read my post again as I addressed both issues.  My notches were as narrow as I could make them with the tool used,  and the notch depth being given in dB, inherently related the noise level in the notch to the original signal level.
Title: SNR of MP3
Post by: greynol on 2012-08-30 15:33:29
In general tests based on subtracting samples are prone to being misleading because there are too many influences that are only weakly relevant that affect their results.  Many have no or very limited bearing on audibility, such as a ten sample time shift which can cause a misleadingly large difference signal.

This doesn't invalidate the legitimacy of the numbers you were reluctant to accept. Moreover, this was the underlying point of those presenting them.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-08-30 16:51:52
In general tests based on subtracting samples are prone to being misleading because there are too many influences that are only weakly relevant that affect their results.  Many have no or very limited bearing on audibility, such as a ten sample time shift which can cause a misleadingly large difference signal.

Of course, it's up to the tester to ensure that the subtraction test is correct. Please be assured that my numbers reflect the actual quantization noise of mp3, not "other influences". Mp3 is basically a waveform coder, so you can easily align the decoded waveform with the original waveform. And there's little correlation between the original waveform and the residual signal.


Please read my post again as I addressed both issues.  My notches were as narrow as I could make them with the tool used,  and the notch depth being given in dB, inherently related the noise level in the notch to the original signal level.

Right, I agree on this. However there are other problems with your test. Mp3 noise does not necessarily increase the signal level in specific frequency ranges, it can also decrease it, esp. in the notches! So, I would not rely on a measurement of the notch depth for noise level estimation, as in some cases the depth can actually increase, but the noise would still be present around the notch.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-08-30 17:24:19
Here is an illustration. Although notches are not very narrow here, I hope the point about the notch depth is made clear.


(http://audio.rightmark.org/lukin/temp/rmm/mp3notch.gif)
Title: SNR of MP3
Post by: pdq on 2012-08-30 17:48:17
I'm a little confused as to what I am seeing. Was the original signal white noise at -50 dB with two notches?
Title: SNR of MP3
Post by: Alexey Lukin on 2012-08-30 17:58:25
Yes. The power spectral density was approx. –50 dB/10 Hz, the overall signal power was –20 dB.
Title: SNR of MP3
Post by: Arnold B. Krueger on 2012-08-30 17:59:35
I'm a little confused as to what I am seeing. Was the original signal white noise at -50 dB with two notches?


Kinda sorta. The original signal appears to have spectral characteristics that are stationary and have a very smooth, broad frequency distribution, such as we would see with a random noise signal.

Note that the signal was not at -50 dB. It is a signal that filled the FFT bins to the -50 dB point which is also dependent on the number of bins. The signal could have easily been just a few dB below FS.

When we are analyzing the performance of perceptual coders, the well-known  and highly significant statistical differences between random noise and music make any results obtained that way very questionable.  The example provided tends to support the previous statements of its author.

I used a recording of real-world acoustic music for my evaluations.

Also, I performed my evaluation at two significantly different bit rates, and compared the differences.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-08-30 18:05:45
You'd get the same results on music too, provided that notches have similar widths and positions to my white noise example. I used white noise as a simple example of the fact that mp3 quantization may either reduce or increase the apparent signal level in certain frequency bands.
Title: SNR of MP3
Post by: Arnold B. Krueger on 2012-08-30 18:18:17
You'd get the same results on music too, provided that notches have similar widths and positions to my white noise example. I used white noise as a simple example of the fact that mp3 quantization may either reduce or increase the apparent signal level in certain frequency bands.



That's just it Alexey, I didn't get the same results on music for the reason I gave.  Using noise signals to evaluate the technical performance of MP3 encoders is a well-known path to pessimistic results.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-08-30 18:33:19
But you didn't use the notches that I used. Anyway, here's a similar result on real music:

(http://audio.rightmark.org/lukin/temp/rmm/mp3notchmusic.gif)
Title: SNR of MP3
Post by: Arnold B. Krueger on 2012-08-30 19:19:41
But you didn't use the notches that I used. Anyway, here's a similar result on real music:

(http://audio.rightmark.org/lukin/temp/rmm/mp3notchmusic.gif)



No, I used notches around 400 Hz and 2 KHz, cause that is where the music usually is.

You did get the MP3 encoder to deepen the notch which probably happened because the encoder figured out that your relatively high notch band was masked and was didn't need to be budgeted any bandwidth.

My bands, focused into the realms  where the ear is pretty sensitive, went the other way, degree depending on the amount of available data bandwidth.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-08-30 20:36:31
When you put notches at lower frequencies, what you see after the encoding is mostly a subband leakage (or aliasing), not a quantization noise.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-08-30 20:42:24
I still think that the best way to measure mp3 noise is to do a subtraction test.
Title: SNR of MP3
Post by: pdq on 2012-08-31 14:52:41
The SNR of an MP3 is around 25-30dB.  Does this mean that I only need to decode them to 6-bit PCM to capture all the details?

So, after all of the back and forth of how to measure the SNR of an mp3, has this question been answered?
Title: SNR of MP3
Post by: dhromed on 2012-08-31 15:28:58
It's probably going to be really noisy, even if nothing is subjectively drowned in the noise.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-08-31 19:31:18
The SNR of an MP3 is around 25-30dB.  Does this mean that I only need to decode them to 6-bit PCM to capture all the details?

So, after all of the back and forth of how to measure the SNR of an mp3, has this question been answered?

The answer is obvious: no, 6-bit PCM is not sufficient.
Title: SNR of MP3
Post by: Arnold B. Krueger on 2012-08-31 20:07:39
I still think that the best way to measure mp3 noise is to do a subtraction test.


I can't think of a worse general way to measure anything than subtraction tests, because they frequently conflate a myriad of differences into one signal.
Title: SNR of MP3
Post by: benski on 2012-08-31 21:08:46
The SNR of an MP3 is around 25-30dB.  Does this mean that I only need to decode them to 6-bit PCM to capture all the details?

So, after all of the back and forth of how to measure the SNR of an mp3, has this question been answered?


It was a rhetorical question.  Of course it's not enough to capture the output of MP3.  LPCM's quantization noise is spread out evenly across the entire spectrum (noise-shape dither can do some juggling, but not much), but of course MP3 has low distortion levels "where it counts". 

The main point of bringing up the subject, and I hope everyone gets the point, is that simply taking the SNR or THD+N and dividing by 6.02dB and saying "use this many bits" is not an accurate model.
Title: SNR of MP3
Post by: greynol on 2012-08-31 21:58:13
Ignoring that people may have missed the point or are simply ignoring the point in order to argue a different one and then nitpick when things don't go their way, maybe you could offer some insight as to how you arrived at the figure you provided?
Title: SNR of MP3
Post by: 2Bdecided on 2012-09-03 09:50:15
The main point of bringing up the subject, and I hope everyone gets the point, is that simply taking the SNR or THD+N and dividing by 6.02dB and saying "use this many bits" is not an accurate model.
...but looking at the minimum point in the noise floor, and figuring out how many bits are needed to preserve that, works pretty well (see LossyWAV).

Cheers,
David.

Title: SNR of MP3
Post by: Neuron on 2012-12-29 17:30:36
What is the THD+N of 16-bit 44.1 Khz PCM?
Title: SNR of MP3
Post by: greynol on 2012-12-29 17:52:03
-96dB without playing games with dither and it's all N; there is no THD.

Perhaps a little research into digital sampling is in order?
Title: SNR of MP3
Post by: Neuron on 2012-12-29 18:04:45
Anyways, anyone who ever heard a 6-bit PCM file knows this is funny. 6-bit PCM is incredibly noisy and it is the equivalent of the rough maximum resolution you can do with digital audio on the PC Speaker. Yes, I mean that little tiny beeper.

Here is a short part of a 192 kbps mp3 bitcrushed to 6-bits:
http://www.hydrogenaudio.org/forums/index....showtopic=98564 (http://www.hydrogenaudio.org/forums/index.php?showtopic=98564)
Title: SNR of MP3
Post by: saratoga on 2012-12-29 21:21:47
Anyways, anyone who ever heard a 6-bit PCM file knows this is funny. 6-bit PCM is incredibly noisy and it is the equivalent of the rough maximum resolution you can do with digital audio on the PC Speaker. Yes, I mean that little tiny beeper.

Here is a short part of a 192 kbps mp3 bitcrushed to 6-bits:
http://www.hydrogenaudio.org/forums/index....showtopic=98564 (http://www.hydrogenaudio.org/forums/index.php?showtopic=98564)


To be clear, MP3 does not work the same as PCM.  128kbit/s @ 44.1k is 2.9 bits per sample.  Throw in ~ 2:1 lossless compression and you get very roughly 6 bits per sample.  Actually when I tried this via the subtraction method (and using WMA rather then MP3) I got closer to 5 bits per sample.  This puts a hard limit on the SNR because you only have a few bits, thus noise will be large as in your sample.  However, lossy codecs are quite clever about distributing that quantization noise, and so you will find that 2.9 bits/sample on mp3 sounds quite a lot better then 6 bits/sample PCM.
Title: SNR of MP3
Post by: IgorC on 2012-12-29 22:44:23
In other words SNR is not enough representative metrics. It doesn't take  psychoacoustics into account.
Title: SNR of MP3
Post by: Neuron on 2012-12-29 23:05:18
So what would be the "percievable SNR" for an average mp3?
Title: SNR of MP3
Post by: greynol on 2012-12-29 23:28:37
What do you mean?

The whole point of this discussion is that applying SNR as a metric to qualify MP3 is a lot more than just a little silly.  SNR of MP3 is low, or far lower than what people would normally deem acceptable from a hi-fi system. The lower it can go without being noticed or found offensive, I'd say the better the encoder is doing its job.
Title: SNR of MP3
Post by: saratoga on 2012-12-30 01:45:10
So what would be the "percievable SNR" for an average mp3?


What do you think perceivable snr would mean?
Title: SNR of MP3
Post by: Woodinville on 2012-12-30 02:42:10
The LP noise floor is rather high- maybe -70dB under very good conditions. 12-bit sampling (RMS noise floor of -72dB) would be sufficient for LP use as long as your levels are right (peak signal above -6dB). (12-bit sampling was used for DV but hasn't seen any other widespread use).


The SNR of an MP3 is around 25-30dB. 



In which alternative universe? At what ludicrously low bit rate?

SNR is a measurable quantity. I've measured it in high-bit rate MP3s. The exact number escapes me but I seem to recall some number north of 80 dB. It was so high that I questioned the use of bandwidth to maintain it.


The SNR of a good-sounding MP3 will be in the 30dB range. Dynamic range is much, much higher. Consider it floating-point like.

This is not alternative universe, this is perceptual coding 101.
Title: SNR of MP3
Post by: Woodinville on 2012-12-30 02:44:05
I still think that the best way to measure mp3 noise is to do a subtraction test.


You're still dead one right, too!
Title: SNR of MP3
Post by: Woodinville on 2012-12-30 02:47:47
I still think that the best way to measure mp3 noise is to do a subtraction test.


I can't think of a worse general way to measure anything than subtraction tests, because they frequently conflate a myriad of differences into one signal.


Since MP3 has no phase shift or frequency shaping to speak of, delay-compensated direct difference is exactly the right way to measure SNR.

In fact, it's ALWAYS the right way to measure SNR, which is formally mathematically defined as

SNR = sum( (x*x))/sum( (x-y)^2)

So Arny, you're right that it makes little sense in perceptual terms, which is why I say in my talks "SNR is mostly useless for perceptual purposes".  None the less, SNR is the relevant question when asking "bits of resolution", courtesy of Mr. Shannon.
Title: SNR of MP3
Post by: Woodinville on 2012-12-30 02:49:17
Of course, as a later codec using noiseshaped DPCM showed clearly, 6 bits/sample is more than sufficient, but there is substantial noise shaping as well as power adaptation.
Title: SNR of MP3
Post by: Neuron on 2012-12-30 09:23:13
Of course, as a later codec using noiseshaped DPCM showed clearly, 6 bits/sample is more than sufficient, but there is substantial noise shaping as well as power adaptation.


Pardon my ignorance, but which codec is that? And 6-bit DPCM does in fact have more bits of resolution, given that it encodes sample differences, not the samples themselves. 4-bit ADPCM ordinarily gives around 10-14 bit of resolution, even without any dithering or noise shaping.
Title: SNR of MP3
Post by: itisljar on 2012-12-30 10:15:30
I don't get it. If I encode 1 kHz at 0 dB to mp3, will that mean I will get noise at -30 dB?
I find that hard to believe. Is there any sample that I can use to measure noise level in some program like Audacity, for example?
Title: SNR of MP3
Post by: Woodinville on 2012-12-30 11:09:07
Of course, as a later codec using noiseshaped DPCM showed clearly, 6 bits/sample is more than sufficient, but there is substantial noise shaping as well as power adaptation.


Pardon my ignorance, but which codec is that? And 6-bit DPCM does in fact have more bits of resolution, given that it encodes sample differences, not the samples themselves. 4-bit ADPCM ordinarily gives around 10-14 bit of resolution, even without any dithering or noise shaping.



You're missing the key point, look-ahead noise shaping, ala Jayant-Noll A*DPCM.

I also think you're confusing dynamic range with SNR.

The paper was from the dire end of Lucent and its subsequent slit into a bunch of companies.
Title: SNR of MP3
Post by: Woodinville on 2012-12-30 11:12:06
I don't get it. If I encode 1 kHz at 0 dB to mp3, will that mean I will get noise at -30 dB?
I find that hard to believe. Is there any sample that I can use to measure noise level in some program like Audacity, for example?



You can use any music you want, just time-align your before and after, and then give on a gain of +1 and the other -1.

You can believe what you want, and with a single sine wave, you will get more than 30dB even though you don't need it, but you really need to understand how noise shaping works in a perceptual coder.

You are aware of the "13dB Miracle" yes?
Title: SNR of MP3
Post by: saratoga on 2012-12-30 18:02:34
I find that hard to believe.


That 5 or 6 bits worth of information has a lot more quantization noise then 15 or 16?  What about that is unexpected?
Title: SNR of MP3
Post by: Neuron on 2012-12-30 20:47:07
I find that hard to believe.


That 5 or 6 bits worth of information has a lot more quantization noise then 15 or 16?  What about that is unexpected?


Yes, but MP3 is not 5 or 6 bit PCM. It is a 32 bit floating point file that contains lossily compressed information which is stored in a non-PCM way. Some guy on this forum once said that mp3 files vs. wav files are like vector graphics files vs bitmap files. By the type of reasoning some people think here, MIDI files would be around perhaps 0.001 bit.

A file with 2.9 bits of resolution would divide the waveform into only cca 7.4 steps and distort the sound wave into a near-squarewave shape. It would be unlistenable even with the most clever dithering and noise shaping in the universe unless you sampled it at megahertz rates, which mp3 definitely does not do.

And LPs can definitely not be stored in just 12 bits. SNR does not tell the whole picture. Quantization error is not "noise", it is ugly disharmonic distortion. Dither prevents that, but it increases dynamic range only, the SNR is actually worse. A dithered 12 bit recording would get rid of most of the distortion, but it would have more noise than an LP. The reason why tapes and LPs are sampled at 16 or 24 bits when digitalizing is that the noise floor of a tape or an LP is very different from digital quantization "noise". You can actually hear signals below the noise level on analog mediums while on undithered digital the signal just drops off.

A CD is definitely superior to LP in noise level, however this does not apply to low resolution digital recordings. A cheap 1980s tape boombox and an 8-bit file might have a similiar SNR, but the tape boombox will sound better as the noise on it is just hiss while 8-bit file will have an ugly, swishy noisy distortion sound in the quiet parts. That is because quantization noise is not static or white noise, it is just how our ears percieve a "steppier" waveform. I am no analog fanboy, but digital quantization error definitely sounds worse than analog noise. That is the same reason why an overdriven tube/transistor analog distortion pedal creates cool rock/metal guitar sounds while digital clipping creates horrible sound. Try digitally clipping a guitar recording in Audacity, you are not going to get a cool rock sound, you are gonna get some seriously horrible sound. Both phenomena are caused by clipping, but forms of clipping are very different from each other just like forms of noise.
Title: SNR of MP3
Post by: Nick.C on 2012-12-30 21:09:54
The 2.9 bits/sample quoted is not a literal 2.9 bits for every sample - rather an average. Not all samples are stored equally in MP3.
Title: SNR of MP3
Post by: Neuron on 2012-12-30 21:17:00
The 2.9 bits/sample quoted is not a literal 2.9 bits for every sample - rather an average. Not all samples are stored equally in MP3.


Yes, but still, 2.9 bits would divide the waveform into only 7 steps. A sine wave would look like a rough stairway. This is clearly not the case with MP3.
Title: SNR of MP3
Post by: lvqcl on 2012-12-30 21:33:24
No, MP3 doesn't store wave data in PCM format.
Title: SNR of MP3
Post by: Neuron on 2012-12-30 21:43:03
No, MP3 doesn't store wave data in PCM format.


That is my point. So it does not follow at all that the "bit resolution" of mp3 is only 2.9 bits.
Title: SNR of MP3
Post by: lvqcl on 2012-12-30 21:54:14
True, but if the SNR of an mp3 file is 18dB then one can say that this is 18/6.02 = ~3 bits.
Title: SNR of MP3
Post by: Neuron on 2012-12-30 22:08:55
Bit depth is not a measure of signal to noise ratio. It measures the amount of bits per sample and the number of steps it is therefore divided into. Even a signal that is just 18 dB above white noise will sound much better than a sound wave trunicated into just 7 possible steps. Would a signal that is just 18 dB above a constant sound of horse farts be "3-bit"?

Bit rate reduction produces a very specific form of audible degradation and one that is far from either hiss or mp3 artifacts. It is the result of making the waveform "blockier".

Saying a random signal with a SNR of 18 dB is 3-bit is like saying a camera image covered with vaseline has a resolution of 320x240. It is apples vs. oranges. People should stop trying to put non-PCM things in PCM terms. I can "record" a sine wave 30 seconds long, 200 Hz frequency by just writing "play sine wave 30 seconds, 200 Hz" with theoretically no noise in just a few tens of bytes. Does that mean the sine wave has in fact a "bit depth" of only say 0.0000001 bits and a SNR of 0.00006 dB despite being described perfectly? I do not think so.
Title: SNR of MP3
Post by: saratoga on 2012-12-30 23:26:47
Bit depth is not a measure of signal to noise ratio.


No it basically is in so far as the amount of information determines the maximum SNR. 

It measures the amount of bits per sample and the number of steps it is therefore divided into.


For PCM audio this is correct, but MP3 is not PCM.  MP3 is a lossy transform codec.  It has nothing analogous to PCM's quantizer step sizes, so anything you assume about it involving quantization steps will not be correct.
Title: SNR of MP3
Post by: Neuron on 2012-12-30 23:39:39
What does "noise" mean in the case of mp3s anyways? How would that noise sound if it wasn't masked? What does a 2.9 bit depth even mean for mp3? How does a codec with ~30 dB signal to noise ratio have a dynamic range of ~150 dB? Honest questions, lossy compression is really starting to confuse me  .

And what is the effective SNR of mp3? As in, does an average mp3 sound like a linear PCM file with a SNR of 96? 90? 80? 75? 70?

If mp3 has a signal to noise ratio of only 15-30 dB, how come it is close to the original sound not only when listening but also when looking at it in an audio editor? How come the waveforms are similiar to the original and don't look or sound noisy at all? If it was all psychoacoustic tricks and the waveform was in reality a noisy, 2.9 bit mess, it would show up in an audio editor. Yet there are no obvious faults except for a lowpass for the highest frequencies.
Title: SNR of MP3
Post by: Glenn Gundlach on 2012-12-30 23:46:51
Bit depth is not a measure of signal to noise ratio.


No it basically is in so far as the amount of information determines the maximum SNR. 

It measures the amount of bits per sample and the number of steps it is therefore divided into.


For PCM audio this is correct, but MP3 is not PCM.  MP3 is a lossy transform codec.  It has nothing analogous to PCM's quantizer step sizes, so anything you assume about it involving quantization steps will not be correct.


Its has SOME relation to PCM  as its final destination is a PCM DAC whether in my car, PC or some other player.


Title: SNR of MP3
Post by: saratoga on 2012-12-30 23:49:03
What does "noise" mean in the case of mp3s anyways?


See Woodinville's post above. 

How would that noise sound if it wasn't masked?


Masking is the process of making something in audible.  Masked noise is therefore inaudible.   

What does a 2.9 bit depth even mean for mp3?


(128000 bits/second) / (44100 samples/second) = 2.9 bits per sample.  Thats all it means.

How does a codec with ~30 dB signal to noise ratio have a dynamic range of ~150 dB? Honest questions, lossy compression is really starting to confuse me  .


Dynamic range has nothing to do with SNR.  The former is just the ratio of the largest magnitude to the smallest, while SNR is the ratio of the maximum signal value to the noise power.
Title: SNR of MP3
Post by: saratoga on 2012-12-31 00:00:22
And what is the effective SNR of mp3? As in, does an average mp3 sound like a linear PCM file with a SNR of 96? 90? 80? 75? 70?


'Effective SNR' is kind of meaningless in this context, but I would say that since MP3 files are generally transparent, and 16 bit PCM is generally transparent, 16 bit PCM is a good format to use with decoded mp3 audio. 

If mp3 has a signal to noise ratio of only 15-30 dB, how come it is close to the original sound not only when listening but also when looking at it in an audio editor?


This is because the dB scale is logarithmic, so a 30 dB SNR will result in an error that is on average just 1/31.623 of the signal, which is quite small by eye.
Title: SNR of MP3
Post by: Neuron on 2012-12-31 00:04:59
What does "noise" mean in the case of mp3s anyways?


See Woodinville's post above. 

How would that noise sound if it wasn't masked?


Masking is the process of making something in audible.  Masked noise is therefore inaudible.   

What does a 2.9 bit depth even mean for mp3?


(128000 bits/second) / (44100 samples/second) = 2.9 bits per sample.  Thats all it means.

How does a codec with ~30 dB signal to noise ratio have a dynamic range of ~150 dB? Honest questions, lossy compression is really starting to confuse me  .


Dynamic range has nothing to do with SNR.  The former is just the ratio of the largest magnitude to the smallest, while SNR is the ratio of the maximum signal value to the noise power.


So the 2.9 bit/sample figure for mp3 does not represent resolution, just mathematics? And how would mp3 noise sound if it was unmasked?
Title: SNR of MP3
Post by: saratoga on 2012-12-31 00:21:35
So the 2.9 bit/sample figure for mp3 does not represent resolution, just mathematics?


What does resolution even mean in this context?

Maybe now would be a good idea to read up some more on PCM, particularly how SNR is calculated.

And how would mp3 noise sound if it was unmasked?


Subtract off the signal and listen for yourself.
Title: SNR of MP3
Post by: Neuron on 2012-12-31 00:25:16
So the 2.9 bit/sample figure for mp3 does not represent resolution, just mathematics?


What does resolution even mean in this context?

Maybe now would be a good idea to read up some more on PCM, particularly how SNR is calculated.

And how would mp3 noise sound if it was unmasked?


Subtract off the signal and listen for yourself.


Thanks, but I don't know how to subtract the signal. And I know the PCM SNR formula is roughly 6.02*number of bits. However a 3 or 5 bit PCM file looks and sounds atrocious while the supposedly 2.9 bit mp3 sounds and looks very close to the original.
Title: SNR of MP3
Post by: Neuron on 2012-12-31 00:38:08
And what is the effective SNR of mp3? As in, does an average mp3 sound like a linear PCM file with a SNR of 96? 90? 80? 75? 70?


'Effective SNR' is kind of meaningless in this context, but I would say that since MP3 files are generally transparent, and 16 bit PCM is generally transparent, 16 bit PCM is a good format to use with decoded mp3 audio. 

If mp3 has a signal to noise ratio of only 15-30 dB, how come it is close to the original sound not only when listening but also when looking at it in an audio editor?


This is because the dB scale is logarithmic, so a 30 dB SNR will result in an error that is on average just 1/31.623 of the signal, which is quite small by eye.


Thanks for clarifying this more, but about the SNR, how come 5-bit PCM (~30 dB SNR) files are so obviously blocky then? And I don't mean at some low sample rate but 44.1 Khz.
See picture of a file bitcrushed to 5-bit in Audacity:
http://i46.tinypic.com/2ro27uw.png (http://i46.tinypic.com/2ro27uw.png)
http://i46.tinypic.com/142wm04.png (http://i46.tinypic.com/142wm04.png)

A 3-bit (18 dB SNR) example looks like it was run over by a steamroller and then set on fire (and it sounds as horrible as it looks):
http://i48.tinypic.com/1zfzex.png (http://i48.tinypic.com/1zfzex.png)
http://i45.tinypic.com/30kd2cg.png (http://i45.tinypic.com/30kd2cg.png)
Title: SNR of MP3
Post by: greynol on 2012-12-31 00:43:05
Wow, we've gotten deep in the rough on this one.

There are plenty of nice descriptions about how mp3 works on this forum. For the love of all that is sacred, please look up one of them.
Title: SNR of MP3
Post by: saratoga on 2012-12-31 00:45:26
And I know the PCM SNR formula is roughly 6.02*number of bits.


Yes, and my suggestion is that you read up on how that number is calculated.

Thanks for clarifying this more, but about the SNR, how come 5-bit PCM (~30 dB SNR) files are so obviously blocky then?


Because your audio editor isn't plotting it right. Again, now is a REALLY good time for you to read up on how PCM works.  You're not going to get anywhere with compressed audio without first understanding more about how uncompressed audio.
Title: SNR of MP3
Post by: Woodinville on 2012-12-31 02:45:34
Yes, but MP3 is not 5 or 6 bit PCM. It is a 32 bit floating point file that contains lossily compressed information which is stored in a non-PCM way.


No.  Please, folks, look up how MP3 works. Please.
Title: SNR of MP3
Post by: Woodinville on 2012-12-31 02:49:20
So the 2.9 bit/sample figure for mp3 does not represent resolution, just mathematics?

It is mathematics, bit depth resolution in the frequency domain, required by the shannon theorem, and is what it is, period.  Don't try
Quote
And how would mp3 noise sound if it was unmasked?


http://www.mp3-tech.org/programmer/docs/CaveT2002.pdf (http://www.mp3-tech.org/programmer/docs/CaveT2002.pdf)

Try it and find out.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-12-31 15:17:56
I don't get it. If I encode 1 kHz at 0 dB to mp3, will that mean I will get noise at -30 dB?

Amount of mp3 noise depends on mp3 bitrate and signal complexity. Generally, tonal material is easier to compress and it results in less noise. If you take a mono file with 1-kHz tone, mp3 noise will only be around –60 dB (for bitrates between 64 and 160 kbps). But if you take more complex recording, your noise will be higher.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-12-31 15:19:05
Also note that the noise from 1-kHz tone will mostly be concentrated at frequencies adjacent to the tone, where it's easiest to mask.
Title: SNR of MP3
Post by: pdq on 2012-12-31 15:36:36
Also note that the noise from 1-kHz tone will mostly be concentrated at frequencies adjacent to the tone, where it's easiest to mask.

Is that really true? I would have thought that inaccuracies in a 1-kHz tone after lossy compression would have been distributed over a wide range of frequencies, especially overtones.
Title: SNR of MP3
Post by: Alexey Lukin on 2012-12-31 15:43:22
Not at all. Since mp3 is a subband coder, a single tone occupies only 1 or 2 frequency bands. And all the quantization noise is concentrated in these 1–2 bands. There is also a small amount of inter-channel leakage in the filter bank, but it is on the order of –90 dB or even less.
Title: SNR of MP3
Post by: pdq on 2012-12-31 16:11:48
OK then, what kind of noise are we talking about that would be adjacent to the tone? Phase noise?
Title: SNR of MP3
Post by: Alexey Lukin on 2012-12-31 18:02:44
Yes, but not only that. Here is the picture. White is your 1 kHz tone, blue is the noise that mp3 encoder adds at 128 kbps.

(http://audio.rightmark.org/lukin/temp/rmm/mp3noise.png)
Title: SNR of MP3
Post by: greynol on 2012-12-31 19:35:13
What is the bit-depth of your source signal used to create that graph and does increasing it change the result?

What if you change the frequency so that it lands perfectly in the middle of one of the MP3's FFT bins?

Does the side-band noise change depending on which bin is being used (by changing the frequency)?
Title: SNR of MP3
Post by: pdq on 2012-12-31 19:43:03
Looking at the white plot, I would guess that the original tone had significantly better than 16 bit resolution.

Edit: What if the frequency is right on the border between two FFT bins?

Edit2: What would happen if you bypassed the encoder with its limitations, and simply generated an mp3 to produce a 1-kHz (or any other frequency) tone?
Title: SNR of MP3
Post by: Alexey Lukin on 2012-12-31 20:11:25
I've used a 32-bit float source and 32-bit float decoding. The sideband products are most likely the filter bank leakage. If you attenuate the tone, they fade too.

Here's how it looks when the signal is aligned with MDCT bins (I hope I did my math correctly by setting f = 1225 Hz).

(http://audio.rightmark.org/lukin/temp/rmm/mp3noisealigned.png)