HydrogenAudio

Lossy Audio Compression => MP3 => Topic started by: airtas on 2019-08-22 17:20:48

Title: Trying to determine which low quality file is better spectral analysis
Post by: airtas on 2019-08-22 17:20:48
Is the blue extending to 22 khz beneficial in the 2nd screen shot?  I think I read that is artifacts but usually I see them slimmer.

Title: Re: Trying to determine which low quality file is better spectral analysis
Post by: DVDdoug on 2019-08-22 18:09:12
You can't tell sound quality by looking at "graphs & pictures".   Listen with your ears! 

I'm sure it's easier to make an MP3 encoder that makes good-looking graphs with bad sound than it is to make an MP3 encoder with good sound.   If you "tweak" the settings for "better-graphs" you are likely to make it sound  worse (with most program material).

MP3 is lossy compression and it's going to throw-away information.  It's trying to throw-away stuff you can't hear.   It doesn't care about what you can, or can't, see in a spectrum.

If you hear something (like a loss of highs) you might be able to see and confirm the problem in the spectrum.   But, if you hear a compression artifact, the loss of highs is usually not what you hear.

Quote
Is the blue extending to 22 khz beneficial
You probably can't hear 22kHz, and even if you can hear "loud" 22kHz test tones with headphones or in soundproof booth during a hearing test, the high-frequency content of "normal music" is at lower level and it's masked (drowned out) by lower frequency sounds.   That's how MP3 (perceptual encoding) (http://www.mp3-converter.com/mp3codec/#80629) "works"...  It analyzes the total-overall frequency content and throws-away drowned-out sounds.

IIRC, the highest "note" in an orchestra is around 8kHz from a piccolo.  The highest note on a guitar is around 1.3kHz.    Of course there are higher frequencies but they are all overtones & harmonics (accompanied by lower-frequency, usually-louder, sounds).    Of course, it is possible  to generate higher notes, even ultrasonic notes, with a synthesizer. 
Title: Re: Trying to determine which low quality file is better spectral analysis
Post by: Porcus on 2019-08-22 19:40:27
As DVDdoug says, if you try to judge quality from spectrograms, you will make mistakes.

That said, there are lossy formats/encoders that introduce noise to substitute for a part of the signal that is removed. The idea is that if you replace a part of the signal by something that sounds alike but takes less number of bits to encode, that would leave space to spend on other parts of the signal. Whether that is what you meant by asking for "beneficial" ...?
There is an option for that in AAC, but your right-hand picture is the MP3.
(Were both encoded from the same lossless source, or have you gone through transcoding?)
Title: Re: Trying to determine which low quality file is better spectral analysis
Post by: ajp9 on 2019-08-22 20:23:31
When it spikes to the top like that, it's clipping. When the original signal is loud enough, particularly at strong points of the codec's frequency curve, an encoder will produce an overall decoded signal somewhat louder than the original, forcing non-floating point decoding to clip to bounds. It may be worth reducing the input gain slightly. (And if you need it at the original intensity, increasing the playback gain by the same amount to compensate.)

In terms of what else it could be, MP3 doesn't have perceptual noise substitution (a la AAC), so that's not what we're seeing in the second image.

In terms of how reliable spectrograms are, they are still reliable in terms of seeing what's missing. I can immediately tell that the MP3 has a lower lowpass.
Title: Re: Trying to determine which low quality file is better spectral analysis
Post by: Porcus on 2019-08-22 21:41:35
It may be worth reducing the input gain slightly.
It is so low in volume that it is not necessarily worth it - and some players will play just fine as long as you don't play on full volume.

Note, for MP3 and AAC (and Opus) you can reduce volume without transcoding. mp3gain or foobar2000.
Title: Re: Trying to determine which low quality file is better spectral analysis
Post by: magicgoose on 2019-08-23 10:51:42
yep, clipping introduced by lossy coding won't be a problem if you decode to floating point and use replay gain and/or some limiter dsp.

also, no, content above 20kHz isn't beneficial, it's better to not keep it (because it can't be heard directly, but sometimes it can cause distortion in lower bands and that's not beneficial)
and if it's clipping, it's affecting the full range, it's just easier to see it above 20kHz because in this case there's nothing else in that range.
Title: Re: Trying to determine which low quality file is better spectral analysis
Post by: magicgoose on 2019-08-23 10:55:42
Quote
The highest note on a guitar is around 1.3kHz.    Of course there are higher frequencies but they are all overtones & harmonics (accompanied by lower-frequency, usually-louder, sounds).
In certain genres like metal, and especially black metal and death metal, it's not uncommon to have guitar tone be the loudest at ~2kHz..6kHz, when there's a lot of overdrive and equalization. These are overtones and harmonics from distortion and whatnot, but they can be louder than the "main" frequencies, sometimes even to the point when it's hard to hear which note is playing but it's still loud af.