[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11. Multimedia Part 1 - Playing and Recording Music

It's easy to enjoy music with Linux, whether you are playing an audio CD, an mp3 or OGG files you recorded yourself onto CDR or hard disk. You can download tracks, or copy them from your own audio cds. While there are plenty of tools for audio work under Linux in both command line and GUI form, I'll be mainly concentrating on the command line as these tools are available on nearly all Linux distributions. Familiarity with the command line tools will also make configuring GUI programs much easier. I'll assume you already have a sound card installed and working.

*Warning*
Breach of copyright is taken very seriously in most parts of the world - this article in no way encourages users to break the law.

11.1 The Basics  
11.2 Playing Audio Cds  
11.3 Playing MP3 Files  
11.4 Using XMMS  
11.5 Recording (or ripping) Tracks from Audio CDs  
11.6 Converting .wav files to mp3  
11.7 The Ogg-Vorbis Format  
11.8 Converting .mp3 files into .wav format  
11.9 To Normalize a group of .wav files  
11.10 Recording (or burning) an Audio CD  
11.11 Recording a Data CD (mp3 or ogg)  
11.12 Some detailed information on related topics:  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.1 The Basics

Since much of this story involves CDs, perhaps we should start with a brief look at both audio and data CDs.

Ordinary audio CDs like the ones you'd play in your home stereo differ from data CDs in that the music is recorded onto the disk as raw data, that is, there is no file system on the disk. That's why if you put an ordinary audio CD into your CD drive and try to read the contents in a file manager, you won't find anything. Your computer is looking for a file system where there is none. An audio CD doesn't need to be mounted to be read or burnt - unlike data disks.

Data CDs on the other hand use a file system to organize the way in which the data is written to and read from the disk, similar to the file system on a hard disk. Music files in formats such as .mp3, wav, or ogg are written onto data CDs using a file system just like any other CDROM. These CDs can be opened in a file manager or from the command line, and the music played using the appropriate program.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.2 Playing Audio Cds

There are several GUI tools available for playing audio CDs. For example Gnome has gtcd, KDE has kscd, and xmms can also play CDs if you have the audio CD plugin enabled. These can be started from the Multimedia section of your menu. From the command line you could try the cdplay program, though it's not very intuitive. Read the manual page (man cdplay) to find out more. Or you can simply use the `play/skip/stop' buttons on your CD drive to play audio CDs.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.3 Playing MP3 Files

The mp3 format is a hugely popular way of storing and sharing music. One reason for its popularity is its compact size compared to other formats or conventional audio CDs. A typical mp3 file is usually only about a tenth of the size of the same file in .wav or audio CD form. This means you can fit the equivalent of ten audio CDs on a single CD using the mp3 format. Other advantages include the reduction in space used when storing music on a hard disk, and the smaller file size also makes transferring files over a network much more practical. The disadvantage is that mp3 CDs can't be played on most normal CD players (although mp3 compatibility is starting to appear on some portable Walkman type players), so you can only play them on your computer. The most popular player for Linux is probably xmms, an excellent clone of the Windows Winamp player.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.4 Using XMMS

Xmms (X MultiMedia System) is a widely used multi purpose sound file player that is included with most common distributions. It's mostly used for playing mp3 files, but it can do much more than that. It is also capable of playing wav files, ogg-vorbis files (an open source alternative to mp3), streaming audio etc. Starting xmms can be done from the menus (look under "Sound" or "Multimedia"), or from a command line just type xmms. The interface is much like that of a CD or tape player, with buttons and sliders to control starting, stopping, pausing. skip, repeat, volume, balance and so on. It also includes an equalizer function (the `eq' button) and allows you to set up play lists. To choose a track to play, hit the L key or press the eject ("^") button. This brings up a window allowing you navigate to the folder holding your music files. Once there, you can select a track or tracks to play, or you can choose to play every file in the folder. As well as the audio options, xmms also has visual options, and different skins can be selected to change the appearance of the player. It can even use Windows Winamp skins. Despite the multitude of options, xmms is exceptionally easy to use. If you want to explore its options and capabilities, click on the small O on the left hand side of the display.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.5 Recording (or ripping) Tracks from Audio CDs

There are several tools for recording audio CDs to hard disk. You can record a single track, selected tracks or the entire CD at once. The music will be converted to a file format that can be read by your computer (usually .wav) as it is recorded. While there are both command line and graphical tools for the job, my favorite is the command line program cdparanoia. If you prefer GUI tools, you might like to check out grip. One of the things I particularly like about cdparanoia is the way it can correct jitters or skips on marked or scratched disks. Here are some examples of how to record tracks from an audio CD using cdparanoia:
To record a single track type:

cdparanoia n

`n` specifies the track number to record. By default the track will be recorded to a file named cdda.wav. If cdda.wav already exists it will be overwritten, so be careful if you are recording several tracks! You can specify your own file name like this:

cdparanoia n filename.wav
To record the entire CD type: cdparanoia -B

The -B in the above command simply ensures that the tracks are put into separate files (track1.wav, track2.wav etc.). Cdparanoia has many more options and an easy to understand manual page; type man cdparanoia to read it.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.6 Converting .wav files to mp3

If you intend to burn files to an audio CD, you should leave them in .wav format. On the other hand, if you want to play them from your hard drive, or burn a data CD that you'll play from your computer, you'll probably want to convert them to the mp3 format to save space. One of the most popular tools for this is bladeenc. To convert a .wav file into a .mp3 use this command:

bladeenc filename.wav

This will produce a file with the same name as the source file, but with the .mp3 suffix. If you want to specify a destination filename you can add it to the end like this:

bladeenc filename.wav filename.mp3

By default, bladeenc will encode the file at 128kbit/sec, this is the most commonly used bitrate and results in a very compact file of reasonable quality. Higher rates can be specified, giving a better sound quality at the expense of a slightly bigger file size, though it's hard to detect any improvement in sound quality using sampling rates above 160kbits/sec. To convert a file at 160kbits/sec use:

bladeenc -160 filename.wav


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.7 The Ogg-Vorbis Format

Ogg -Vorbis is a completely free and open alternative to the mp3 format. The sound quality is at least as good as mp3, and ogg files can be played on players such as xmms. You'll need the vorbis-toolspackage (check your distributions installation CDs) to convert .wav files to .ogg. Converting is easy:

oggenc filename.wav

As with bladeenc, the sampling rate (and sound quality) can be specified. This is done by using the following command:

oggenc -q n filename.wav (where n is the quality level)

The default level is 3, but can be any number between 1 and 10. Level 5 seems to be roughly equivalent to an mp3 encoded at 160kbits/sec.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.8 Converting .mp3 files into .wav format

Audio CDs are usually burned from a collection of .wav or .cdr files - you can't directly burn mp3s to an audio cd unless you convert them to one of these formats. The mpg123 program can do this for you and is often installed by default with many distributions. To convert an .mp3 to a .wav, type:

mpg123 -w filename.wav filename.mp3 (note - the destination filename comes first)

Note also that there is some slight loss of sound quality when a .wav file is converted to mp3 format, and this isn't regained when converting back to .wav - so if possible, you should try to use .wav files that have been ripped from an audio CD rather than converting back from mp3s.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.9 To Normalize a group of .wav files

Creating an audio CD using tracks from different sources can lead to variations in volume amongst the tracks. By using a program named normalize, you can equalize the volume level of a group of files. You'd normally do this to a group of .wav files before burning them to CD. Normalize is a command line tool; to equalize the volume of all the .wav files in a folder type:

normalize -m /path/to/files/*.wav


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.10 Recording (or burning) an Audio CD

I'll assume that you have a CDR or CDRW drive installed and configured already - if you don't, see the links section at the end of this article for more information on set-up details. I'll also assume that you'll be using cdrecord to burn your disks - it's the most popular tool for this and is also what's used by most graphical front-ends like XCDRoast etc. Your files will need to be in .wav or .cdr format; most likely they will be .wavs. Put all the files you want to burn into a separate folder to simplify the burning process, and make sure that they will fit onto the disk (you can check by changing into the folder and running the du command). Now it's just a matter of typing this command:

cdrecord -v speed=4 dev=0,0,0 -audio -pad *.wav

Of course, your speed and device numbers might be different - you can use cdrecord -scanbus to find the device address, and the speed setting will depend on your CD burners' speed rating. In general, burning will be more reliable at slower speeds, especially on older machines.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.11 Recording a Data CD (mp3 or ogg)

If you only plan to play a music CD on your computer or other mp3 capable device, you can burn mp3 or ogg files in exactly the same way as an ordinary data CD. Because data CDs use a file system, we'll use mkisofs (to create the file system) and cdrecord to burn the disk. As in the audio CD example above, put all the files into a separate folder. The two operations can be combined into a single command like this:

mkisofs -R /path/to/folder_to_record/ | cdrecord -v speed=4 dev=0,0,0 -

Don't forget the hyphen at the end! As in the example for burning audio CDs, you might have to use different speed and dev numbers. Older or slower computers might have difficulties running both mkisofs and cdrecord at once - if so you can do it as two separate operations like this:

mkisofs -R -o cdimage.raw /path/to/folder_to_record/

This creates an image named cdimage.raw. Then burn the disk:

cdrecord -v speed=4 dev=0,0,0 cdimage.raw (using suitable speed and device settings..)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.12 Some detailed information on related topics:

The Linux MP3 How-To
The Linux MP3 CD Burning How-To
The SOX Homepage- The swiss army knife of Linux sound tools.
The Normalize Homepage
Installing and Setting Up a CDR/CDRW - *Note* Modern desktop distributions can usually detect and setup a CD burner without any manual configuration required. This page may be useful however for older/difficult distributions that require manualinstallation.
The OggVorbis Homepage
The Bladeenc Homepage
The CDRecord Homepage
The CDParanoia Homepage
The mpg123 Homepage


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated on March, 5 2003 using texi2html
Hosted by www.Geocities.ws

1