Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Understanding spectral analysis of mp3 (Read 8614 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Understanding spectral analysis of mp3

Hello, by looking at these spectograms (http://imgur.com/a/DwPI6) can someone enlighten me why there are some randoms bit ranging above 20khz, does this means it's a bad transcode? Usually all of my mp3 files never goes beyond 20.5khz.

Also, there is another example http://imgur.com/a/6zFQe . Can anyone explain me why they are going way beyond 20khz, is it a sign of a bad mp3 encode?

I'm kinda new at this so please try to explain as simply as possible :)

Re: Understanding spectral analysis of mp3

Reply #1
mp3 performs a lowpass (the cutoff) so that more bits can be allocated to the quality of the frequencies you hear best. So theoretically, yes, these are probably bad encodes, but it's up to you if you can hear a difference with a proper re-encode with lowpass.

 

Re: Understanding spectral analysis of mp3

Reply #2
Let me start at the second spectogram:
That spectogram shows that the encoder didn't use a filter. That's fine, but MP3 has some limitations and in order to maintain all the bandwidth, it might have taken tradeoffs on lower frequencies. Depending on the encoder and the audio, it might or might not matter.

As for the first spectogram, in that one the encoder uses a filter at 20Khz. Such a cuttoff is generally fine (CD players were originally designed to have a gentle lowpass at that frequency), and helps the encoder to distribute more bits into the lower frequencies.

The "peaks" in this spectogram are mosty a consequence of clipping. Clipping is generally shown as a straight line.
Since it is filtered, the line is attenuated. If you look at the range, that's around -90dBs.


Re: Understanding spectral analysis of mp3

Reply #3

As for the first spectogram, in that one the encoder uses a filter at 20Khz. Such a cuttoff is generally fine (CD players were originally designed to have a gentle lowpass at that frequency), and helps the encoder to distribute more bits into the lower frequencies.

The "peaks" in this spectogram are mosty a consequence of clipping. Clipping is generally shown as a straight line.
Since it is filtered, the line is attenuated. If you look at the range, that's around -90dBs.




Right, so I got a few more examples of the same song, it appears all of them have the same peaks, just some have less than others. Also I did try listen to them and couldn't tell a difference. Here are the spectograms http://imgur.com/a/902eY
A little bit later I found a vinyl rip ( http://imgur.com/RG8KqQR ) and it seems this rip doesn't have any peaks, I did listen to, also couldn't tell much of a difference apart from that vinyl rip is lackluster in volume compared to others,  I have to turn in up a bit to equal volume.

And why does vinyl rip scale is up to 24khz while i presume other rip are from cd's and have scale only up to 22khz?

Re: Understanding spectral analysis of mp3

Reply #4
Probably because the vinyl was sampled at 48kHz and the MP3 was created from a CD, i.e. 44.1kHz.
lossyWAV -q X -a 4 -s h -A --feedback 2 --limit 15848 --scale 0.5 | FLAC -5 -e -p -b 512 -P=4096 -S- (having set foobar to output 24-bit PCM; scaling by 0.5 gives the ANS headroom to work)

Re: Understanding spectral analysis of mp3

Reply #5
My impression is that you need some more technical background information to understand this. Forgive me if some of this should already be known to you.

First of all, the top frequency of a spectrogram depends on its sampling rate. Digital audio can capture signal frequencies up to half the sampling frequency, so if you are looking at a spectrogram that ends at 22 kHz, the sampling rate of the corresponding audio file will have been 44.1 kHz, like on a CD. If the spectrogram ends at 24 kHz, you are dealing with a sampling rate of 48 kHz.

If you are ripping an analog source (i.e. vinyl), you decide which sampling rate you are using. If you get the material in digital form, in whatever encoding (MP3, WAV, FLAC, ...), it is already sampled at a sampling rate someone else chose. There are sampling rate converters, which can convert from one sampling rate to another.

When encoding psychoacoustically compressed formats like MP3, the encoder may decide to omit higher frequencies in order to save bits. This is based in its in-built hearing model that allows it to decide which omissions are least objectionable for listeners. Hence, whithin the frequency range allowed by the sampling rate, there may be an unused zone at the top of the range. The encoder makes these decisions dependent on the available data rate, so the outcome may be different for different settings used during encoding.

A decoder ought to reconstruct this faithfully, and this includes that there should be no frequencies produced at the top if the encoder didn't include any. However, the detailed workings of MP3, which I'm not going into, can lead to situations where signal overload happens in the decoder (i.e. clipping). Clipping is a form of distortion, and such distortions are known to produce additional frequencies, called harmonics. Those may fall into the previously unused range at the top end, and you will see it as a vertical line in the spectrogram. Such lines are are telling you that the signal was suffering from distortion, very likely because it was quite loud to begin with. To avoid those distortions, its volume should have been reduced a little before encoding.

This explains why the vinyl rip, which you have described as "lackluster in volume", doesn't show the problem. It was encoded at a level that didn't cause clipping to happen.

Sadly, many CDs are recorded at such "loudness maximised" levels, that encoding it in MP3 is virtually guaranteed to produce problems with clipping, unless their level is reduced by a few dB before encoding. This may not be audible, but it becomes visible in a spectrogram.

Re: Understanding spectral analysis of mp3

Reply #6
My impression is that you need some more technical background information to understand this. Forgive me if some of this should already be known to you.


Thank you, your post definitely gave me a better understanding. As I said in my first post, I'm very new to audio and its specifics.

So basically what I now understand is that these "peaks" in spectograms is a sign of clipping?
Also thanks for describing clipping, I've read a little about it, but didn't really understood and paid attention to it until now.

Re: Understanding spectral analysis of mp3

Reply #7
So basically what I now understand is that these "peaks" in spectograms is a sign of clipping?
Very likely.

It is a telltale sign when those "peaks" happen in places where the signal is loudest, i.e. where the color of the spectrum right below the peak shows the highest levels. The loudest frequencies may be those towards the bottom of the frequency scale, but the distortion they cause may still show up at the top of the frequency scale.

Note also that a linear frequency scale, as commonly used in those spectrograms, is kinda "unnatural" in its relationship with human hearing, which has a logarithmic characteristic. This doesn't make the spectrogram wrong, but it makes it harder to interpret, since the top octave occupies half of the total space on the diagram. The frequency range where most of the musical "action" happens is crammed into a narrow strip at the bottom of the diagram. If you don't know this, and don't read the spectrogram with this in mind, you may be tempted into a false sense of the importance of the top end.

Re: Understanding spectral analysis of mp3

Reply #8
I agree with everything pelmazo has said.

One thing about the exaggerated view of the top end is that it is helpful for spotting the telltale spikes from lossy coding, especially MP3. Examples of what lossy coding does to spectrograms (it's different from the look of clipping) have been posted in other threads, but you can easily make your own.

Re: Understanding spectral analysis of mp3

Reply #9
Let me start at the second spectogram:
That spectogram shows that the encoder didn't use a filter. That's fine, but MP3 has some limitations and in order to maintain all the bandwidth, it might have taken tradeoffs on lower frequencies. Depending on the encoder and the audio, it might or might not matter.

As for the first spectogram, in that one the encoder uses a filter at 20Khz. Such a cuttoff is generally fine (CD players were originally designed to have a gentle lowpass at that frequency), and helps the encoder to distribute more bits into the lower frequencies.

The "peaks" in this spectogram are mosty a consequence of clipping. Clipping is generally shown as a straight line.
Since it is filtered, the line is attenuated. If you look at the range, that's around -90dBs.


can you explain more on the clipping?  Why is the clipping not heard but seen and it is only on super loud tracks?

Re: Understanding spectral analysis of mp3

Reply #10
Quote
can you explain more on the clipping?...

...and it is only on super loud tracks?
Clipping is overload distortion (squared-off waveforms).    You can get clipping on a CD by "trying" to go over the digital maximum (0dBFS), or you can clip your amplifier if you try to get 110 Watts out of a 100W amplifier, etc.

Clipping generates harmonics (multiples of the existing frequencies).   I believe clipping generates odd harmonics.  For example, if you have a pure 1kHz signal and it clips, you will get new frequencies at 3kHz, 5kHz, 7kHz, 9kHz, etc.   Of course, those harmonics will show-up in a spectrum analysis.

Some Loudness War CDs are clipped.   And, distortion does add to the perceived loudness so if loudness is your goal you may want a little distortion.

Quote
Why is the clipping not heard but seen
It depends on how bad it is, the duration, and frequency.   If it's 90dB down you're not going to hear it.   Plus, it may be masked (drowned out) by the other signals.   All real world sounds also contain harmonics and overtones so with normal program material it has to be pretty bad before you hear it as distortion.    If it's near 20kHz you're not going to hear it unless it's very loud, if you can hear that high at all.    But of course, there are (usually) other distortion components between the signal and the highest audio frequencies and these will be heard before you hear distortion near 20kHz.