Understanding MP3: How Does It Work?

  • Thread starter arcnets
  • Start date
  • Tags
    Work
In summary: The command line interface is not required, however, if you want good quality encoding, it's a good idea to use a command line encoder.
  • #1
arcnets
508
0
Hi all,
when you store music as a WAV file (CD quality), it will take ~10 MB per minute. If you compress to MP3, even with the highest quality, you will only get ~1 MB per minute.
I know that the file size is determined by amplitude resolution * sample rate. If you use 16 bit, 44 kHz, and stereo, that results in ~10 MB per minute as I said.
The Shannon theorem says that, in order to digitalize an analog signal with full quality, the sample rate must be at least twice the highest frequency. So you cannot throw away any high-frequency Fourier components, or the sound will be bad.
My question is: How can the MP3 compression give a sound almost as good as the original, while throwing away ~90% of the information?
Does anyone know a simple explanation?
Thanks...
 
Computer science news on Phys.org
  • #2
What MP3 codec does, is that it gets rid of parts of audio that you and I cannot hear.
 
  • #3
I can easily tell the difference between mpw and .wav. When you convert to mp3, the song loses much of its stereo sound/3-d quality. I compared same songs in both formatts and could tell the difference quite easily.

Carlos Hernandez
 
  • #4
Carlos,
Were you using variable bitrate or constant bitrate ?
 
  • #5
Originally posted by BoulderHead
Carlos,
Were you using variable bitrate or constant bitrate ?

Constant, I believe.
 
  • #6
Some software programs may not allow the luxury of opting to encode using variable bitrate but you can obtain better sound quality with this method...just a thought.
 
  • #7
Originally posted by arcnets

The Shannon theorem says that, in order to digitalize an analog signal with full quality, the sample rate must be at least twice the highest frequency.
Actually, Shannon's sampling theorem says nothing about quality. What it says is that to represent a signal of frequency f Hz at all, you must sample at or above 2f Hz. f, the highest frequency representable, is called the Nyquist frequency.

A sine wave digitized at almost exactly the Nyquist frequency will look nothing at all like the original sine wave. All Shannon's theorem says is that its fundamental power will still appear in a frequency-domain plot.

Now, mp3 is not a sampled data stream, so Shannon's theorem doesn't apply to it.

What mp3 basically does is compute a wavelet (or FFT, I can't remember which) transform on blocks of samples. The result is a set of Fourier coefficients. The mp3 algorithm then discards some of these coefficients which are not psychoacoustically important. Voila! You have compressed your data.

- Warren
 
  • #8
Originally posted by BoulderHead
Some software programs may not allow the luxury of opting to encode using variable bitrate but you can obtain better sound quality with this method...just a thought.

I was using the freeware CDex, they had both options available.
 
  • #9
Note to Carlos: the quality of your encoding software matters. A lot.

- Warren
 
  • #10
Originally posted by chroot
Note to Carlos: the quality of your encoding software matters. A lot.

- Warren

Yeah for example 64kb encoding would sound pretty bad, but 192kb encoding sounds great.
 
  • #11
Originally posted by Greg Bernhardt
Yeah for example 64kb encoding would sound pretty bad, but 192kb encoding sounds great.
Not just that -- different encoders, both running at 192kbps, will produce different results.

- Warren
 
  • #12
What I'm referring to as 'almost as good as the original', is:
256 kBit/s, 44100 Hz, Stereo + Resample.
Originally posted by Greg Bernhardt
What MP3 codec does, is that it gets rid of parts of audio that you and I cannot hear.
How does it know what you and I cannot hear? And does this imply that we cannot hear ~90% of the information that is in a soundwave?
 
  • #13
I encoded my .wav into 128, 160, 192, 256, and 320 kbps, and I've tried freeware like CDex, which is supposed to be high quality, but I've also tried high quality shareware, like media jukebox and MusicMatch Jukebox. No matter what the situation, I noticed that you end up loosing significant stereo/3-D sound from the original. And it's not just me, I found that other people also found the same results as I. I searched this on the internet, and others have said the same thing.

Carlos Hernandez
 
  • #14
Try a real encoder, like LAME.

- Warren
 
  • #15
Originally posted by chroot
Try a real encoder, like LAME.

- Warren

All the encoders I used had the Lame feature.

Perhaps I just have a better ear for music and can tell differences better. Or maybe not, who knows.
 
  • #16
This page explains the difference between joint stereo and stereo.

http://www.modatic.net/audio/stereo_vs_jointstereo.php

If your having a problem with your separation, then it's probably the software you are using. The lame encoder that was mentioned is a command line program. It's one of the best encoders. It's free. If your not comfortable with using a command line interface, then you might not like using lame. There are many windows front-ends available but they generally don't use all the features that you get when using the CLI version. Some software may use the lame encoder (lame_enc.dll) but the functionality is usually crippled.

http://lame.sourceforge.net/

I think the info on the first page I linked to will solve your problem.
 
Last edited:
  • #17
Originally posted by arcnets
How does it know what you and I cannot hear? And does this imply that we cannot hear ~90% of the information that is in a soundwave?

one example is that when you have 2 frequencies f1 and f2 very close and the amplitude of f1 is smaller than the amplitude of f2 you cannot hear f1. But the exact parameters (when 2 frequencies are close or what amplitude difference is important is subject to psychoacoustics...).
So the mp3 encoder after computing the wavelet transform (or FFT, whetever...) can safely ignore some of the coeficients based on rules such as the above one.
 
  • #18
Thanks Guybrush T.,
yes I understand. In the case that you mention, the result of the 2 waves superimposing, would be a very long-period, low amplitude modulation in volume, which is ignored by the ear.
Since the lowest audible frequency is ~20 Hz, the Fourier transform will deliver sinus components of 20 Hz, 40 Hz, 60 Hz, and so on. And, of course, say, 10000 Hz and 10020 Hz are 'very close together'.

I have the following idea: Is it possible to construct (mathematically or otherwise) a WAV file that sounds *bad* with any MP3 compression? Because the wave is constructed so tricky that MP3 throws away just the components that are, in fact, important to our hearing?

Maybe a voice whispering some words, barely audible, in a lot of noise?
 
  • #19
Originally posted by arcnets
I have the following idea: Is it possible to construct (mathematically or otherwise) a WAV file that sounds *bad* with any MP3 compression? Because the wave is constructed so tricky that MP3 throws away just the components that are, in fact, important to our hearing?

Maybe a voice whispering some words, barely audible, in a lot of noise?

Actually, there are people who test various encoders using a bunch of different files. You can see what the results are for some pathological sounds like instantaneous pulses.

IIRC mp3 has problems with clicks and pops of some type more than anything else.

Here's a chapter of O'Reilley's book on mp3's. It might be more than what you wanted.

http://www.oreilly.com/catalog/mp3/chapter/ch02.html [Broken]
 
Last edited by a moderator:
  • #20
NateTG,
that's great. Thank you.
 

1. What is an MP3 and how does it work?

An MP3 is a type of digital audio file that is compressed to reduce its size without significantly affecting its quality. It works by removing redundant and irrelevant information from the original audio file, resulting in a much smaller file size.

2. How is an MP3 different from other audio file formats?

An MP3 is different from other audio file formats because it uses a lossy compression algorithm, which means that some data is lost during the compression process. This results in a smaller file size but also slightly lower audio quality compared to lossless formats like WAV or FLAC.

3. How does compression affect the audio quality of an MP3?

Compression affects the audio quality of an MP3 by removing certain frequencies and audio data that are deemed less important. This can result in a loss of some high and low frequencies, which can affect the overall sound quality of the audio file.

4. Can an MP3 be converted back to its original format without losing quality?

No, once an audio file is compressed to MP3 format, it cannot be converted back to its original format without losing some audio quality. This is because the removed data cannot be recovered, resulting in a lower quality audio file.

5. How has MP3 technology evolved over the years?

MP3 technology has evolved significantly since its creation in the late 1980s. The original MP3 format used a compression ratio of 12:1, while modern MP3s can achieve compression ratios of up to 30:1. Additionally, advancements in technology have allowed for better audio quality at smaller file sizes, making MP3s a popular choice for digital audio files.

Similar threads

Replies
7
Views
3K
Replies
9
Views
1K
  • Introductory Physics Homework Help
Replies
3
Views
121
  • Introductory Physics Homework Help
Replies
2
Views
1K
  • Other Physics Topics
Replies
18
Views
2K
Replies
12
Views
2K
Replies
16
Views
2K
Replies
2
Views
2K
Replies
35
Views
8K
  • General Engineering
2
Replies
39
Views
13K
Back
Top