MP3 on Mac OS X

Disclaimer: any opinions expressed in this article are those of its author ( comartin@wicc.weizmann.ac.il ) and do not purport to represent Weizmann Institute of Science policy.

Nota bene: I have migrated to Mac OS X ages ago. The old Macintosh MP3 page is here

What the PC is MP3?

The short answer: MP3 stands for MPEG (Motion Picture Experts Group) Layer 3. It is an audio compression format that on average yields (claimed) near-CD quality at 1:11, and de facto CD quality at 1:6 to 1:8, the size of the original. That is to say, a regular CD, which holds up to 80 minutes of uncompressed music, can hold something like 8-14 hours worth of MP3 files, depending on quality.
MP3 is a so-called "lossy compression" algorithm, which (like JPEG for pictures) takes advantage of the limitations of human perception to achieve very high compression ratios. This stands in contrast to so-called "lossless" algorithms, like GIF for pictures (or Shorten for sound), as well as such popular file compression formats as ZIP on PCs, gzip on Unix systems, and StuffIt on Macintoshes. Lossless algorithms merely exploit repetition, redundancy,... in the original file to arrive at a compressed representation, but do preserve all the details of the original. The upshot is that they generally achieve much lower compression ratios (in the 2:1 range for audio, much higher for images) than lossy algorithms.
For the long answer, check out the  MP3 Technical Info and  FAQ at the  Fraunhofer-Gesellschaft.

Is MP3 encoding legal?

No more or less than taping. That is, encoding one's own CDs for personal use is perfectly legal, but selling MP3 files encoded from commercial CDs, without paying royalties, isn't.

Are there any good encoders for Mac OS X?

The built-in encloder in iTunes 4 will probably do if "Oooh baby do me one more time" is your idea of a musical experience. If you are willing to consider formats other than MP3, and if files with somewhat aggressive "digital rights managements" don't totally turn you off, iTunes' AAC (Advance Audio Coding) encoder is a good alternative. Songs bought at the iTunes online music store are encoded in AAC --- at 128kbps, this encoder cannot be beaten.

The answer for everybody else is LAME (Lame Ain't an MP3 Encoder, in the GNU tradition of recursive acronyms :-). LAME is an open-source MP3 encoder that gives its commercial counterparts a run for their money. People not afraid of Unix command lines can download and compile the source themselves --- but an excellent GUI version integrated with iTunes is available: iTunes-LAME Encoder.

What about MP3 players for Mac OS X

There are a number, but my only experience under OS X is with iTunes.

What bitrates to use? What about variable bitrates?

[These remarks obviously apply to all platforms, not just Mac OS X] Constant bitrate encoding (CBR) uses the same bitrate throughout a track; variable bitrate encoding (VBR) takes a "frame" and tries to encode it with progressively higher bitrates until a certain quality criterion (e.g. deviation from original below a set threshold) has been reached. VBR is on the one hand more economical in disk space than high-bitrate CBR, and on the other hand more homogenous in quality, because it can encode very complex sounds at exceedingly high bitrates (up to 320kbps) that would be wasteful to use for the whole track.

Nowadays, the only good reason to stick with FBR would be if you have an older portable MP3 player (or MP3 discman) that cannot handle VBR. If you need predictable file lengths and the player can handle variable bit rates, then ABR (average bitrate encoding) is the best option, where the encoder will try to come up with a file that has the average bitrate you specify.

I have a large backlog of 128kbps and 160kbps CBR files, all done with LAME or with the old N2MP3 encoder (which is maybe slightly better at 128kbps). Most people will not hear the difference on el cheapo "multimedia speakers". I can assure you that you WILL hear the difference on Apple Pro Speakers (actually made by Harman-Kardon, say no more) --- let alone on a quality stereo system.

What do the VBR presets in LAME correspond to?

In increasing order of quality, taken from HydrogenAudio: --alt-preset standard is said to be "transparent" in that even on professional audio equipment, double-blind listening tests have found it indistinguishable from the original except for some pathological samples (generally from either extreme metal genres or electronic music). --alt-preset extreme gives additional headroom.
--r3mix used to be the "gold standard" and will come very close to "transparency". On Apple Pro Speakers, neither I nor the missus (a professional musician by training) can tell r3mix apart from either "--alt-preset standard" or the original. However, if hard disk space is not a burning issue and you want files more or less upwardly compatible (should you ever get a "real" stereo system, and I don't mean an overgrown boombox with 15 different "bass bomb" buttons ;-)), you can't go wrong with --alt-preset standard.
UPDATE: apparently the definition of r3mix changed drastically somewhere between versions 3.92 and 3.95. The equivalent command line switches recommended on the r3mix bulletin board were apparently (if I understand correctly: caveat lector): -b128 -V1 -h -mj --lowpass 19.5 --athtype 3. (Using LAME 3.95, "As I Am" by Dream Theater [a very "busy" prog-metal track], encoded at 236kbps with these switches, compared to 224kbps with --alt-preset standard and 180kbps with the new --r3mix preset. Interestingly enough, the same track with the --r3mix preset in LAME 3.90.3 clocks in at 220.7 kbps, but 190.2 kbps with the supposedly equivalent command line switches. Apparently subtle changes in the "psychoacoustic model" in the various versions are responsible for the differences.)

Some actual bitrate comparisons between --r3mix and --alt-preset standard (LAME 3.95):
Descriptionr3mixstandard
Bach (arr. Busoni): Ich Ruf Zu Dich BWV639 (quiet piano)137143
Bach (Yo-Yo Ma): Prelude from cello suite in G major, BWV1007 (solo cello)140163
Bach (Perlman): Fugue from G minor sonata BWV1001 (solo violin)167193
Beethoven (Kempff): Adagio from Hammerklavier Sonata Op.106173172
Beethoven (Karajan): Scherzo from 9th Symphony Op.125189222
Bach (Gould): Goldberg Variations BWV988 (bright uptempo piano)184206
Bach (Walcha): Toccata in D minor BWV565 (full organ)191219
Donald Fagen: I.G.Y. (jazzy pop, very clean recording)172195
Dream Theater: The Glass Prison (progressive metal)174216
Tangerine Dream: Tangram set 1 (electronic music)176199
Sci-fi movie buffs may recognize the organ chorale "Ich Ruf Zu Dich" as the theme of the classic movie "Solaris". (The test sample was a piano arrangement by Busoni, played by Nikolai Demidenko. I picked it because LAME 3.90.3 --r3mix yields a bizarrely low bitrate of 96kbps for this: in fact, it appears to have this tendency with quiet and muffled tracks in general.

Speed: on an Apple iMac G4 1.25GHz, "--alt-preset standard" encodes about 3 times faster than realtime, "--r3mix" 4.5 to 5 times. (In both cases, the CD was previously copied to hard disk. iTunes-LAME can do this for you automatically.)

Another comparison, this time with four different Dream Theater tracks:

LAME versionCommand line parameters (1) (2) (3) (4)
3.95 --insane 320 320 320 320
3.95 --extreme 267 263 263 288
3.95 -b128 -V1 -h -mj --lowpass 19.5 --athtype 3 227 231 238 238
3.95 --alt-preset standard 210 217 220 224
3.95 --r3mix 177 186 183 180
3.90.3 --r3mix 217 222 185 221
3.90.3 --alt-preset standard 233 230 205 235
original CD (not applicable) 1411141114111411
(1): "6:00" from "Awake". Very "busy" track with fast bass line and lots of percussion, aside from their usual distortion guitars, orchestral keyboards, and theatrical singing.
(2): "Erotomania" from same album. Busy instrumental.
(3): "Space Dye Vest" from same album. Quieter, spacey track (except for closing section).
(4): "As I Am" from "Train of Thought". Most sonically intense track of the lot.

Can you hear the difference with the original?

Depends on the bitrate the MP3s were encoded at, as well as the quality of your speakers (or your sound system, if you are feeding the audio output of your computer into an external amplifier). Also depends on the kind of music: roughly from easiest to hardest: spoken word, solo cello, solo violin, solo piano, ordinary pop music, orchestral classical music, classical organ music, electronic music, heavy metal rock. Historic monaural recordings, as well as material with very little stereo image (solo acoustic guitar or violin) are especially easy to reproduce. Most "oldies" were recorded on equipment that would make even 128kbps MP3 look "hifi" by comparison. Music that spans across the entire sonic spectrum, has many non-harmonic components (like percussion instruments) as well as sudden dynamic changes, is comparatively hard to reproduce. (That's what accounts for high bitrates in VBR of heavy metal, where very deep bass [especially when 5-string bass guitars are used] and bass drums are combined with distorted guitars full of harmonics and bright cymbals that reach all the way to the top. Low-bitrate MP3s of such material will mess up either the bass or the cymbals.)

I am a Unix geek and prefer the command line interface. Or I just want to see the bitrate histogram in a VBR encode. Can I "break out" the LAME executable from iTunes-LAME?

Yes. Right-click (or control-click, if you have a 1-button mouse) on the package, and pick "show package contents" from the contextual menu. A Finder window with the contents will open. Double-click "contents", then "resources". Near the bottom, you will see "lame". Option-drag to the Desktop to make a copy. Now close the "resources" and "contents" windows.

You can use the opposite procedure to install a new LAME binary into the iTunes-LAME front-end.

Can iTunes-LAME encode a whole bunch of CDs at once?

Sure. Put in the 1st CD. Pick "Encode Using LAME..." from the AppleScript menu (there should only be the one item). In "Preferences" set both "Cache tracks to hard disk" and "put LAME version in comment" (which will actually put the exact encoder flags so you can remember what you did). Enter the encoding options in the command line, then hit the "Import" button in the "iTunes-LAME" window (NOT the big iTunes window). You will hear a "Pok!" when it finishes copying the CD.

Now hit the "Eject CD" button (top right key on recent Apple keyboards); take out the encoded CD and put in the next one; close the tray; wait for iTunes to access CDDB and retrieve track names etc.; now SHIFT-click on the "Import" button in the small iTunes-LAME window (NOT the big iTunes window). The next CD will now be cached while the machine continues to encode the previous one. Again wait for the "Pok!", and repeat as necessary. The main limiting factor is disk space for the cached copies and MP3 files (to be on the safe side, 600 MB per hour of music). I just jacked in 20 CDs in a row without any apparent problem.

What is the difference between Stereo and Joint Stereo? Which should I

use? "Stereo" encodes both channels separately and uses exactly one-half the bitrate for each. "Joint stereo" encodes the sum L+R and the difference L-R separately, and allocates bitrate to the sum and difference channels based on the relative magnitude of sum and difference channels. On material with little stereo image, L+R will get nearly all the bitrate, and sound quality will be way superior to a "Stereo" encode at the same bitrate. Electronic music tends to be full of sound effects/enhancements that rely on stereo separation, and MP3s at low fixed bitrates of such material may sound better in Stereo than in Joint Stereo. In variable bitrate encodes, joint stereo is generally recommended regardless of music genre.

What are "Shorten" and "Apple Lossless"?

These are lossless audio compression algorithms ("Apple Lossless" was first introduced in iTunes 4.5). On average, either algorithm will give you 2:1 compression if you're lucky (!), but being lossless, the original source can be reconstituted exactly, and somebody else who gets your CD can make "shorten"ed files without loss of quality. (This unlike lossy compression: if you burn an audio CD from decoded MP3 files for somebody, and this person makes their own MP3 files from it, significant loss of quality will occur.) For that reason, Shorten is very popular among fans of bands that allow concert taping and concert tape trading (e.g. the Grateful Dead, Phish,... ), since the original CDs can be reconstituted, recompressed, ... ad nauseam. See here or here for an example: the "Tangerine Tree" project, a pyramidal nonprofit fan distro of live recordings of the German electronic music ensemble Tangerine Dream.

xACT is an all-purpose Shorten tool for Macintosh.

Links

  • iTUnes LAME encoder. Two versions are given: one based on the latest LAME (3.95 at the time of writing), another based on LAME 3.90.3 which many audiophiles still prefer. (This is primarily relevant if you swear by the old --r3mix settings; in that case you should perhaps consider upgrading to --alt-preset standard.)
  • LAME at sourceforge.net
  • Mirror of old r3mix bulletin board (original is dead)
  • Hydrogen Audio
  • WikiPedia entry on MP3
  • Audacity, a powerful freeware audio manipulation program for Mac OS X; see also The Amazing Slow Downer.
  • Comments? Write  comartin@wicc.weizmann.ac.il

    Back to computational chemistry home page