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: Trying to learn to understand spectral analysis of mp3s (Read 35145 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Trying to learn to understand spectral analysis of mp3s

I'm trying to learn how to determine the quality of an mp3 file from the audio spectrum.

I have two copies of the following track - the first is a higher bit rate, but the spectrum of the second track looks cleaner to me?




The second copy of the track was sourced from iTunes so I'd expect it to be pretty good quality. I can't remember where I got the first from, but it's supposed to be 320kb

Here's another 320kb track that I find a bit dodgy - am I right to find it dodgy, or is this ok?



Finally, if anyone knows of any good tutorials, or sources of further info on how to interpret these kind of spectrums, I'd appreciate it. I'm just starting out as a DJ, so checking through my music to reduce the likelihood of a bad sound over a PA.

Re: Trying to learn to understand spectral analysis of mp3s

Reply #1
just convert lossless file to mp3 few times with different bitrates and notice the difference. that's the best way to learn.

Re: Trying to learn to understand spectral analysis of mp3s

Reply #2
I'm trying to learn how to determine the quality of an mp3 file from the audio spectrum.

That isn't really possible.  Spectrogram mainly shows you what lowpass setting was used, and not much else. 

Re: Trying to learn to understand spectral analysis of mp3s

Reply #3
One other thing you can check for is high frequency tones.
As a teen, i couldn't stand listening to Radiohead's All I Need, because i could hear a 16kHz tone all through it.

It's the only commercial song i've run into that had that problem, though.

Re: Trying to learn to understand spectral analysis of mp3s

Reply #4
The wide bar in the first sample is a remainder of strongly shaped dither, which is common on CDs. Although it is hard to tell at this magnification level, the second copy might be from a different source, with flat or no dither.

You could evaluate the "density" of spectral information: how frequent and wide "holes" in the higher frequencies are. The third sample would definitely look suspect by this criteria. However, it might be a legitimate encode from an older Fraunhofer encoder (which is part of many software packages like Cool Edit or Sound Forge), which encodes signal above 16 kHz only when it is quite loud, doesn't use the bit reservoir (at 320 kbit), and often pads the encode with unused bytes.

If the band up to 16k is reasonably dense, with few holes, the file is likely not a transcode. Likewise, if the encoder has preserved a relatively quiet dither up to 19-20k.

Like Bero1707 said; you could also try different encoders, vbr/cbr modes.

Re: Trying to learn to understand spectral analysis of mp3s

Reply #5
Thanks for the replies.

I hadn't realised there was quite so much to it, but starting to realise. Never heard of dither before, but having read up a bit on it, it makes sense.

I did read elsewhere about the problem with Fraunhofer encoder - Pretty sure I used to use that, which is likely why the third sample looks like it does.

Regarding sound quality - my understanding was that if you had a 16k cut off with lots of spikes protruding through it, there was likely to be sound distortion due to clipping?

"If the band up to 16k is reasonably dense, with few holes, the file is likely not a transcode."
This bit I don't understand - I'd have thought a solid band up to 16k with a sharp cut off at 16k would strongly imply a transcode from low bitrate? What am I misunderstanding?
Also what do you mean by a "quiet dither"? Is the first image I posted an example of this?

Thanks

Re: Trying to learn to understand spectral analysis of mp3s

Reply #6
I hadn't realised there was quite so much to it ...


A moderately easy question to answer: What sounds can we remove because they are at frequencies that most people will not hear anyway? And if that was all there was to lossy encoding, then lots of people, invluding those of us with little or no programming skills, could have a go at writing such a thing

A much harder question to answer: What sounds can we remove because they are masked by other sounds and won't be heard because of that? Now we are talking what I, maybe naively, consider to be genius engineering and programming skills. It's a huge leap.

 
The most important audio cables are the ones in the brain

Re: Trying to learn to understand spectral analysis of mp3s

Reply #7
Yes, clipping (during decoding) would appear as lines extending to the nyquist frequency, well above any lowpass cutoff. You need to zoom in closer to greater time resolution to see those lines. At zoom factors similar to your samples, and the Fraunhofer encoder, you might see few isolate drum hits "prodtruding" above 16k, not necessarily clipped.

I'm guilty of using imprecise language earlier. If the recording in question didn't have loud treble, a normal encode produced with FhG could have very little above that that threshold. But spectrum below it would show some "dropouts" at lower bitrates (perhaps around 11-12 kHz), but very few of those at 320 kbit, as illustrated in figure "mp38.jpg" on the linked site.

If low level, high frequency signals, including dither and pilot tones, are clearly visible on a spectrogram, the sample likely has a high bitrate. At low bitrates, but high or no lowpass, there might be some spikes at high frequencies, but without enough bandwidth, and encoder would most of the time not preserve unimportant low level noises accurately.

Re: Trying to learn to understand spectral analysis of mp3s

Reply #8
Quote
I'm trying to learn how to determine the quality of an mp3 file from the audio spectrum.
Listen with your EARS, not your eyes.   ;)    Sometimes you can tell if a file is lossy or not by looking at the spectrum, but you can't judge the sound quality.

I'm pretty sure it's easier to make a good looking spectrum than it is to make a good-sounding file...    And, I know  I can make a lousy-sounding (uncompressed) file with a good-looking spectrum.   

You can modify the MP3 parameters to keep more of the high frequencies and that should give you a better looking spectrum.  But, MP3 is lossy and it's going to throw-away some  information.   It's usually best to let MP3 "do it's thing" and throw-away sounds that you can't hear because they are masked by other sounds.   If you force it to keep something you can't hear, it might throw-away something you can hear, making it sound worse!    Don't worry what the spectrum looks like.

If you want to be a perfectionist or you're paranoid, don't use lossy files.

Quote
The second copy of the track was sourced from iTunes so I'd expect it to be pretty good quality. I can't remember where I got the first from, but it's supposed to be 320kb.
iTunes are AAC, not MP3.   In some cases AAC can be better.   But in most cases, a high-quality (high bitrate) MP3 (and AAC) will sound identical to the uncompressed original (in a proper. scientific, level-matched, blind, ABX Test).   If both files SOUND identical to the original, we can't say one is "better".  

Quote
I'm just starting out as a DJ, so checking through my music to reduce the likelihood of a bad sound over a PA.
In most DJ situations there's lots of background/crowd noise and sometimes bad acoustics.     So, the quality of the recording isn't super-critical.   And, if you've got an awesome-sounding system with big speakers & big amps, it's going to sound awesome anyway, unless your recordings are horrible.    Most listeners are not that critical, MP3s can be very good, and they can't A/B or ABX against the original, so nobody is going to know!  ;)

If you can hear MP3 artifacts in a particular recording, you are most-likely to hear them when listening carefully with headphones.
 

But, I have had the opposite situation...   The first time I heard MP3s it was from a PA system.     The high frequencies sounded somehow-distorted, and I just assumed it was because of lossy compression.     But now that I've learned how good a good-quality MP3 can sound, I'm not sure...    Maybe it was crappy low-bitrate MP3s, or maybe it was the crappy piezo tweeters, or maybe it was just turned-up too loud.     It was a long time ago and I don't remember exactly what it sounded like, but I wasn't impressed...

Re: Trying to learn to understand spectral analysis of mp3s

Reply #9
The thing I've noticed most with mp3s, mainly with classical music, has been horrible distortion at certain points.
Admittedly this was back in the day when I compressed everything to 128kb :o

More recently I've sourced tracks of Youtube that weren't available anywhere else, which often results in a file with at best 160kb, and again I've noticed some of these sound horrible at certain points.

I suppose my worry is that any defects are going to be exacerbated by a louder PA system. So a track which sounds ok on my Pc speakers, suddenly distorts like crazy when pumped out at 3 times the volume. Is this a valid concern? If not then I'll quit worrying :)

I'm NOT particularly worried about a track sounding inferior to a lossless version, since it's unlikely anyone will pick up on even a 128kb encoding unless there is distortion.



Re: Trying to learn to understand spectral analysis of mp3s

Reply #11
The thing I've noticed most with mp3s, mainly with classical music, has been horrible distortion at certain points.
That might have been because something was clipping. Or because of bugs in the encoder. Without further investigations, you can't tell where the problem came from. MP3 at 128kbit/s doesn't distort horribly when used correctly. The predominant experience is that the encoded version is hard to distinguish from the original.

Quote
More recently I've sourced tracks of Youtube that weren't available anywhere else, which often results in a file with at best 160kb, and again I've noticed some of these sound horrible at certain points.
If you can't compare them with an unencoded reference, you can't say where the distortion came from. Distortion is quite often on the original record already, and no encoding can do anything about it.

Or there is a problem in the way you play the files. The distortion may originate after the decoding. You have got to investigate the case properly before jumping to conclusions.

Quote
I suppose my worry is that any defects are going to be exacerbated by a louder PA system. So a track which sounds ok on my Pc speakers, suddenly distorts like crazy when pumped out at 3 times the volume. Is this a valid concern? If not then I'll quit worrying :)
Sure, at some point your playback system will distort when you crank up the volume. That's to be expected. You've got the Problem of figuring out at what point in the signal chain the distortion sets in first. It may be a simple case of having set the volumes somewhere in the chain in a way that clips prematurely.

Re: Trying to learn to understand spectral analysis of mp3s

Reply #12
Regarding distortion, look at the waveform view, instead of the spectrum view, of the compressed file.  Does the signal stick to the roof or bottom out at any loud parts?

Re: Trying to learn to understand spectral analysis of mp3s

Reply #13

I thought I would get some intelligent answers on here, but it seems that my post has also attracted a number of trolls.

If you can't usefully contribute to a discussion, please don't bother to post, particularly when it's clear that you haven't actually read and understood my OP. Particularly those commenting on blind hearing tests, since that is completely irrelevant to my question which had NOTHING to do with what is or is not removed from a compressed audio track.

Thank you Joe and j7n for answers that add to my knowledge.


Re: Trying to learn to understand spectral analysis of mp3s

Reply #14
I'm trying to learn how to determine the quality of an mp3 file from the audio spectrum.
Answer: You really can't. At best you may be able to determine if it is from a lossy rather than from a lossless source, but it could still be audibly indistinguishable from a lossless original.

I'm sorry if that was not the answer you were looking for.

Re: Trying to learn to understand spectral analysis of mp3s

Reply #15
They weren't trolling you; they were trying to explain why your question is flawed. They understood what you were asking just fine, but problem is that you actually cannot determine "quality" or what is "removed" (apart from frequency filtering, such as a lowpass filter) just by looking at a spectrograph.

Re: Trying to learn to understand spectral analysis of mp3s

Reply #16
I'm trying to learn how to determine the quality of an mp3 file from the audio spectrum.
That is not the proper way to determine the quality of an mp3 file.

Calling me a troll doesn't change this simple fact.

Re: Trying to learn to understand spectral analysis of mp3s

Reply #17
So since my topic got locked (sorry for not searching the forum greynol).  Does this mean...

Code: [Select]
*MP3 file, Bitrate 64 kbps. Cut-off at 11kHz.
*MP3 file, Bitrate 128 kbps. Cut-off at 16 kHz.
*MP3 file, Bitrate 192 kbps. Cut-off at 19 kHz.
*MP3 file, Bitrate 320 kbps. Cut-off at 20 kHz.
*M4A file, Bitrate 500 kbps. Cut-off at 22 kHz.
*FLAC file, Lossless quality (Bitrate usually 1000 kbps or higher). Graph's drawn continuously, no cut-off.

and kHz goes "straight across" in the spectrogram is bullshit?

I am a bit confused on your response greynol, because you said
Quote
You determine bitrate from the size of the audio data and its duration.
  You can transcode a 128 kbps MP3 to 320 kbps and that will increase the size and also fool whatever audio player, foobar for example, into thinking it's actually a 320 kbps MP3.

Re: Trying to learn to understand spectral analysis of mp3s

Reply #18
Yes bullshit, read this thread.


Re: Trying to learn to understand spectral analysis of mp3s

Reply #20
Code: [Select]
*MP3 file, Bitrate 64 kbps. Cut-off at 11kHz.
*MP3 file, Bitrate 128 kbps. Cut-off at 16 kHz.
*MP3 file, Bitrate 192 kbps. Cut-off at 19 kHz.
*MP3 file, Bitrate 320 kbps. Cut-off at 20 kHz.
*M4A file, Bitrate 500 kbps. Cut-off at 22 kHz.
*FLAC file, Lossless quality (Bitrate usually 1000 kbps or higher). Graph's drawn continuously, no cut-off.

M4A file, Bitrate 61 kbps. Cut-off at 20.5 kHz.
[EDIT]Didn't notice I am in the mp3 forum, so it may be off topic? mp3PRO can make the spectrum looks full in low bitrate as well although it requires a compatible decoder.


Re: Trying to learn to understand spectral analysis of mp3s

Reply #22
Code: [Select]
*MP3 file, Bitrate 64 kbps. Cut-off at 11kHz.
*MP3 file, Bitrate 128 kbps. Cut-off at 16 kHz.
*MP3 file, Bitrate 192 kbps. Cut-off at 19 kHz.
*MP3 file, Bitrate 320 kbps. Cut-off at 20 kHz.
*M4A file, Bitrate 500 kbps. Cut-off at 22 kHz.
*FLAC file, Lossless quality (Bitrate usually 1000 kbps or higher). Graph's drawn continuously, no cut-off.

M4A file, Bitrate 61 kbps. Cut-off at 20.5 kHz.
[EDIT]Didn't notice I am in the mp3 forum, so it may be off topic? mp3PRO can make the spectrum looks full in low bitrate as well although it requires a compatible decoder.
But M4A/AAC is suppose to preserve more frequencies than MP3, so it makes sense it would cut-off higher.  Though 61 kbps yeah that is too high.

Here's my FLAC of Blues Breaker's Hideaway.  Then I converted to 320 kbps with LAME and 160 kbps with LAME in Foobar.  Seems pretty accurate when comparing with that kHz list above.






Re: Trying to learn to understand spectral analysis of mp3s

Reply #23
I converted to 320 kbps with LAME and 160 kbps with LAME in Foobar.  Seems pretty accurate when comparing with that kHz list above.
Based on one version of one encoder on one sample.  That's a far cry from being universal.

How much high frequency preserved depends on the encoder, settings, and content being encoded.

But M4A/AAC is suppose to preserve more frequencies than MP3
Supposed to?!?

Can you quote the relevant portions in each of the specifications in order to corroborate this?

That you think so, was able to see it with one specific implementation, or read it on reddit doesn't make your statement correct.  It's supposed to do what the specific encoder decides to do; nothing more, nothing less. 

Hopefully someone will correct me if I'm wrong, aren't the specifications for mp3 and mp4 defined for the decoder?  If this is the case, then the encoder can do whatever the developer(s) decide, provided they create a compliant stream.

EDIT: Sorry, I meant AAC. Mp4 is just the container.

Re: Trying to learn to understand spectral analysis of mp3s

Reply #24
Well I converted the same FLAC to a 96 kbps Ogg Vorbis and it's slightly above 16 kHz which is accurate with what I've read - not saying it's the truth!

Why would people spread all this misinformation about bit rates in correlation to spectrograms?  I mean Spectro, another popular spectrogram program says this right on the front page of their website... 
Quote
Spectro lets you view vital data about compressed audio files and creates a spectrogram of the wave data. This allows you to quickly and easily spot quality issues with a file and also look for transcodes.
Spectro will soon support an automatic transcode detection feature and will be able to scan your music library for suspect files.