Linux is a Killer Platform for MP3s — Here’s How to Get Up and Rocking

MP3 digital audio is the hottest and most controversial technology advancement to hit the music industry since the tape recorder -- the notion of being able to compress multiple CDs' worth of music into a fraction of the space, customize your own music playlists, and listen to volumes upon volumes of your favorite music on your PC while doing other tasks has the personal-computing hobbyists in a frenzy and has the music-recording industry in an uproar over intellectual-property issues. Linux, no stranger to controversy itself, just so happens to be one of the best platforms there is for playing and recording your own MP3s.

Desktop XMMSskin1
Desktop bizarre-XMMS-skins
Slip Into a New Skin: Choose your own look and feel with XMMS.

MP3 digital audio is the hottest and most controversial technology advancement to hit the music industry since the tape recorder — the notion of being able to compress multiple CDs’ worth of music into a fraction of the space, customize your own music playlists, and listen to volumes upon volumes of your favorite music on your PC while doing other tasks has the personal-computing hobbyists in a frenzy and has the music-recording industry in an uproar over intellectual-property issues. Linux, no stranger to controversy itself, just so happens to be one of the best platforms there is for playing and recording your own MP3s.

Linux’s rock-solid performance, multithreading capabilities, and low CPU overhead make it an ideal OS where every little clock cycle counts, and MP3 encoding is about as processor-intensive as you can get. Making your own MP3s on Linux may sound like black magic to you, but it’s really quite easy once you’ve learned the basics. To get started, the first thing you’ll need is an MP3 encoder.

Choosing Your Encoder Software

An MP3 encoder is a software application that takes the raw digital bit image of a song track extracted from a CD and converts it into an MP3 file that can then be played back using an MP3-player program. This explanation is a huge oversimplification; the actual science of producing MP3 music files involves a lot of complex math algorithms with interesting-sounding names like Fourier wave transformations, band-bit allocation routines, and psycho-acoustic models, but as an end user none of that stuff is really important to you.

The most important concept in understanding how MP3 encoders work is the trade-off that exists between sound quality on the one hand and bit rate and file size on the other. When you create an MP3 file, you have an option of specifying something called a bit rate — effectively how much you want to compress the audio stream. The higher the bit rate, the larger your MP3 output file is and the better your sound quality will be (and the longer it will take to encode the file). Typically, acceptable audio quality can be achieved with a 128-160 Kbps bit rate for stereo music on a basic PC-powered speaker/16-bit soundcard setup.

If you have a more sophisticated sound card and speaker configuration (such as Creative’s SoundBlaster Live! using digital SPIDIF output with the Creative FPS2000 4-speaker/subwoofer combination) or are piping the audio output to a home stereo receiver, then you’ll want to encode your files at a higher rate, anywhere from 256Kbps to 320 Kbps, which will deliver true CD-quality music.

On page 73, we’ve listed a few of the MP3 encoders that we’ve tried. All four of these encoder programs are command-line-based and in and of themselves cannot directly turn a CD track into an MP3 file. For that, you’ll need a CD-ripper program to extract the file from your CD, and a front-end GUI to combine the encoder and the ripper functionality.

DAE, Rippers, and Front Ends

Desktop grip-interface1
Get a Grip: Mike Oliphant’s Grip ripper-encoder is one of the best.

In last month’s column about CD recording, we touched on the subject of Digital Audio Extraction, or DAE. Part of the tedium in producing MP3 files is the time that it takes to extract the track data from a music CD and to write it to a binary file on your hard disk, such as a .WAV file. Depending on the DAE capabilities of your CD reader, reading a three-minute song track can take a matter of seconds or several minutes — try to rip an entire CD with a drive with slow DAE capabilities, and you’ll soon understand why fast DAE is important, as is the data-transfer rate of your CD-ROM drive.

If you’re going to take up encoding MP3s as a serious hobby, you’ll want to invest in a fast CD-ROM drive with fast DAE or “ripping” capabilities, like my trusty Plextor UltraPlex 40Max SCSI-2 reader that can do DAE at 24x speed. There’s a great page on the DAE benchmarks for many CD-ROM drives at the CD Speed home page, in case you’re wondering which CD reader to purchase. At the time of this writing, the fastest CD-ROM read-er on the planet was Kenwood’s True-X 72X ATAPI drive ($120.00 street price), which was benchmarked at 46.1X speed for DAE.

Desktop xmms1
Bringing Color to Your Music: The XMMS player (above) lets you visualize what your MP3 files might look like (see result below).
Desktop XMMS-visalizatinpgn

Once you’ve picked a fast CD-ROM reader, you’ll need a ripper program. The most popular one for Linux is cdparanoia (check the Web Links sidebar below for URLs to this and other software mentioned in this article), which is open source and free. It’s available as a compiled and statically linked x86 Linux ELF binary, but if you intend to use it with Linux on a non-Intel platform, you’re going to have to compile it yourself. Fortunately, it’s compiled using GNU automake, so once you’ve downloaded it, all you need to do is run ./configure, make all, and make install from the source tree. In addition, there’s also the cdda2wav ripper software.

To put everything together in a nice, cozy, user-friendly interface, you’ll need a ripper-encoder front end. There are numerous ripper-encoder front ends to be found on Freshmeat and various other places, but of all the ones I’ve tried, Mike Oliphant’s Grip 2.9 is the best one so far. You can compile Grip 2.9 by yourself using GNU automake, but the binary is also
available as an RPM file. Grip is programmed for the GTK+ environment, so you’ll want to make sure the GTK+ 1.2 libraries and glibc 2.1 are installed on your system. (If you’re using a
recent version of Red Hat, Mandrake, SuSE, Caldera, or Corel, or have the GNOME environment installed, you’re good to go.)

Grip 2.9 has some really cool features, including:

* cdparanoia ripper is built-in, so you don’t have to compile it separately.

* Supports cdparanoia and cdda2wav external rippers.

* Supports the BladeEnc and LAME MP3 encoders.

* Built-in CD-player program

*Auto-identifies the CD and accompanying track info in the drive by connecting to the CDDB freedb.org Internet database.

* Rips and encodes in separate processes, so you can extract the current track while the last track is being encoded.

Once you’ve encoded your first few MP3s, you’ll want to listen to them. To do that, you’re going to need an MP3 player.

MP3 Players

There are quite a few MP3-player programs for Linux, some of which may already be installed on your system, like Kmp3, which is included in the default KDE 1.1.2 setups of most distributions. But by far the best one out there is the X Multimedia System
(available as source or precompiled RPM files), or XMMS for short. XMMS isn’t as much an MP3 player as it is a way of life for some people — not only can you play MP3s with it, but, with special plug-in files, you can produce all kinds of weird visualization effects on your screen with OpenGL and you can pipe your audio stream into ICECAST servers, which let you broadcast your MP3 music over the Internet. In addition to MP3, XMMS also allows you to play a whole bunch of other media formats, like .WAV. But perhaps the most popular aspect of XMMS is that it supports “skin” files, which allow you to customize the look and feel of the program, some of which are pretty interesting and odd-looking. If you use Red Hat 6.1 or Mandrake 7, XMMS is already installed on your system.

For a minimalist approach, you may want to check out mpg123, which is a command-line player, in the event you don’t care about skins or are too macho for a GUI. Installing mpg123 is a prerequisite to running XMMS as well, since it functions also as an audio driver.

Of course, you’ll want to be sure that you have a soundcard installed and that the appropriate driver is either loaded as a module or compiled into your Linux kernel. If you have a Red Hat or Mandrake distribution, you should be able to just run sndconfig at the terminal prompt to auto-detect and set up your soundcard. Other distributions, like SuSE, Caldera, and Corel, have their own configuration programs, so check with your Linux distribution’s manual for details.

Getting MP3s from Other Sources

Desktop napster-search-eng
Finding MP3s: The Napster client brings the world to you.

Here’s where we get into the real gray areas of MP3, and where the music-recording industry goes ballistic — the distribution and exchanging of MP3 files over the Internet.

While the legality of creating and listening to MP3 files for your own personal use either from CDs that you own or from .WAV files that you record yourself (for example, if you’re a basement rock band looking for attention) is still being debated in the courts, the matter is much clearer when it comes to music that is copyrighted. Such music cannot be distributed over the Internet without the express permission of the recording artist or music recording company, and is classified by the 1997 No Electronic Theft (NET) Act (H.R. 2265) as a felony crime subject to six years of imprisonment and heavy fines.

That being said, Linux Magazine in no way condones the unauthorized distribution of copyrighted digital audio over the Internet.

MP3 files are distributed in any number of ways, including the traditional methods of Usenet postings in *.binaries newsgroups, on clandestine FTP sites, in IRC chat channels, and through e-mail. However, one of the most popular and effective ways of distributing MP3 files is via an online MP3-sharing community, such as Napster.com.

Essentially, what Napster and services like it do is allow hundreds of thousands of users to simultaneously pool their MP3 collections on their local hard disks, the locations of which are updated at a central database (in this case, Napster.com). Via a special client program, you can search this central database for any particular music you want.

The resulting searches allow you to anonymously download the MP3 music files directly from the hard drives of the computers with the files, which in theory absolves Napster.com from any legal responsibility. Still, the Recording Industry Association of America filed a lawsuit against Napster. com in December of last year.

There are several other open source Napster clients available for Linux as well — just do a quick search on Freshmeat.net.

Happy MP3ing!

A Handful of Encoders

Desktop XingMP3encoder-otpt
The Fastest There Is: $20 spent on the Xing encoder can save you some time.

Here’s a list of four MP3 encoders for Linux, and what we like and dislike about them:

Xing MP3 Encoder 1.5 is a commercial MP3-encoder program that is by far the fastest one in existence but trades off encoding speed at the expense of sound quality. If your PC’s CPU is lagging behind in processor speed (400 Mhz or less) or if your soundcard/speaker setup isn’t a premium one, then spend the extra money on the Xing encoder, as it will save you a lot of time. Xing’s encoder also runs on PowerPC machines, which is nice if you’re running Linux on a Mac. $19.95, http://www.xingtech.com

Fraunhofer Institute’s MP3Enc 3.1, another commercial MP3 encoder, is considered to have the most sophisticated MP3-encoding algorithm with the highest-quality output at the lower bit rates (128 K or below) but is expensive, and is also the slowest one available. Ifyou have a fast CPU and have the cash to spend, MP3Enc is a good choice. $199, http://www.iis.fhg.de/amm/download/mp3enc/index.html

BladeEnc .91 gives you the best of both worlds — it’s about the middle of the road in terms of speed, it produces extreme good quality audio, and it’s free, as in free speech and free beer. Since the BladeEnc code is open source, it compiles on every platform Linux runs on, including the screamingly fast Alpha. I had the pleasure of compiling and running this on a dual-processor 667 Mhz Alpha 21264 UP2000 system from Alpha Processor, Inc. recently — truly a hardware platform and software combo meant for encoding MP3, if you have to do it professionally and in a New York minute. BladeEnc’s project leader, 24-year-old Tord Jansson from Norway (why does it seem all these bright programmers are from everywhere but the United States? Is this a pattern?) claims that BladeEnc produces best results at 160 K bit rates and above. The BladeEnc Web site is also a good place to go for links and general information about MP3. BladeEnc comes as either source or RPM files, which is nice if you don’t like compiling your own software. Free, http://bladeenc.mp3.no

LAME is an another really good free MP3encoder (actually, LAME is a patch to the freely available but copyrighted ISO MP3 demonstration source code that makes it into a usable MP3 encoder) that claims very high speed and near-Fraunhofer sound quality. It’s also got some cool noise-shaping capabilities and can encode MP3 files with Variable Bit Rate (VBR) using an intelligent encoding algorithm that raises and lowers the bit rate during the process to maximize audio quality while minimizing file size. Free, http://www.sulaco.org/mp3

Web Links


* BladeEnc http://bladeenc.mp3.no

* LAME http://www.sulaco.org/mp3

* MP3Enc http://www.iis.fhg.de/amm/download/mp3enc/index.html

* Xing MP3 Encoder http://www.xingtech.com

CD Ripper Software

* cdparanoiahttp://www.xiph.org/paranoia

* cdda2wavftp://ftp.gwdg.de/pub/linux/misc/cdda2wav/

Ripper-Encoder Front Ends

* Grip http://www.nostatic.org/grip

* RPM format of Grip http://www.nostatic.org/grip/grip-2.91-1.i386.rpm

MP3 Players

* X Multimedia System http://www.xmms.org

* mpg123http://www.mpg123.de/

More Links

* CD Speed’s DAE benchmarks http://users.pandora.be/erik.deppe/cdspeed2.htm

* freedb Internet database http://freedb.freedb.org

* Napster http://www.napster.com

* MP3.com — a portal site for legal MP3s http://www.mp3.com

Jason Perlow is a contributing editor with Linux Magazine and is president of Argonaut Systems, a New Jersey-based systems integration firm. He can be reached at perlow@hotmail.com.

Comments are closed.