Take All Your Music To Linux

“I own many CDs”, the Sphinx said. “I listen to music all the time. But I never play my CDs. What is happening?”

That’s easy, a minor-league Sphinx question at best. She ripped her CDs. She used software to read the audio data, convert it to a compressed format, and store the songs as files to play on her computers.

Linux has the tools to rip and play music, let’s see how.

Music Linux

Pick a Codec: Size Versus Quality

A codec or encoder/decoder is an algorithm that converts between audio signals and digital formats. CDs contain data encoded as PCM or Pulse Code Modulation. It’s 16 bits per sample, two channels, 44,100 samples per second. So, about 10 MB per minute of audio. You could just rip your files to PCM files, typically named *.wav, but this gets large fast.

We hear a lot about the MP3 codec. People say “My MP3s” to mean “My music files”. MP3 is a lossy compression algorithm. It uses psycho-acoustics, models of human perception of sound. It reduces the data size with limited, hopefully acceptable, loss of quality. You can select varying quality levels. At higher quality most adult humans can’t notice any difference between the original PCM and the slightly lossy, slightly wrong, MP3 version. High-quality MP3 files are only about 10% the size of the original.

If you consider yourself a true audiophile, and you’re not too concerned about storage size, consider FLAC, the Free Lossless Audio Codec. Just as its name says, it compresses audio without losing any information. FLAC compresses typical content down to 50-60% the original size without loss or distortion.

Either lossy or lossless, compression depends on what you give it. Highly complex input (Bach fugues, some jazz) doesn’t compress as much, more ambient and less complex (Brian Eno, Sigur Rós) compress more.

You can, of course, use a variety of codecs on your collection. Baroque in FLAC, punk and Nordic metal in MP3, let’s say.

Installing the Software

I recently told you how to install software to play multimedia on Red Hat Enterprise Linux, clones like CentOS, and close derivatives like Oracle Linux and Scientific Linux. This builds on package management techniques you learn in Learning Tree’s Linux server course. If you have added MP3/MPEG player support you’re almost there.

First, add Grip, a graphical front end for ripping audio CDs. There are alternative tools, but Grip makes things very easy.

Then add the LAME encoder for MP3, or the FLAC encoder for the audiophile approach.

These free tools are widely available. I use the same tools on my Linux deskop at home and my OpenBSD laptop on the road.

Getting Started

Start Grip and load an audio CD. With a live Internet connection, here is what I see after I click the column header Rip to select all the tracks for ripping:

Grip screen to select what to rip and convert.

Grip reads the table of contents from the CD and connects to freedb.org. That provides the names of the artist, album, and tracks. It won’t find everything, but it finds a lot. It found and named Sufi music for whirling dervishes, Turkish pop music, Bulgarian Orthodox liturgical music, and more that I brought back from trips. Click the Config tab then DiscDB to select more databases.

Grip streen to configure codec.

Don’t proceed until Grip is getting metadata from freedb.org and naming the directories and files. You don’t want to try to organize a bunch of unknown_cd_01 albums containing 01_track_01.mp3, 02_track_02.mp3, and so on.

Specify your encoder and its command line as seen below. The -h option means “high quality”, and the various -t* options insert metadata in the file listing the title, artist, album, and so on. You don’t have to be a command-line guru. What you see here is Grip’s default behavior.

Grip screen configuring codec

Results are stored under ~/tmp/ within your home directory, in directories named for albums. File names start with a 2-digit track number (01, 02, …) and then the title. That means that when I tell Audacious or similar to play an album, it will play the tracks in the intended order.

Ripping and Converting

Go to the Rip top-level tab and select Rip+Encode.

In this screenshot Grip has read tracks 1 and 2 from the CD and stored them as PCM files. It is much of the way through reading track 3. Meanwhile, it has finished converting track 1 to MP3 and is two-thirds of the way through track 2. Once it converts the PCM file into an MP3 version, it deletes the large *.wav file.

Grip screen showing ripping and encoding progress.

Continuing

Now it’s just a matter of feeding CDs into the tray, clicking the Tracks tab and selecting all tracks, then clicking the Rip tab and then the Rip+Encode button.

Then create subdirectories of ~/mp3 for artists, and move the directories from ~/tmp to the appropriate locations.

Now I can take all my music with me on a trip to teach a Learning Tree class or work on a consulting project. I can play whatever I want as the mood strikes me. All my CDs stay in boxes in the back room at home.

image sources

  • grip-01: Bob Cromwell
  • grip-02: Bob Cromwell
  • grip-04: Bob Cromwell
  • grip-03: Bob Cromwell

Type to search blog.learningtree.com

Do you mean "" ?

Sorry, no results were found for your query.

Please check your spelling and try your search again.