[Ed. Note: This article is based on Bruce Fries' book Digital Audio Essentials.]

There are so many types of audio files out there that it's all too easy to end up with the wrong one. Maybe you converted your CD collection to Real Audio or WMA and now want to convert the songs to a nonproprietary format, such as MP3, so you can play them with iTunes. Or maybe you purchased songs in a copy-protected AAC format from the iTunes Music Store and need to convert them to MP3 so they'll work in your portable player, handheld computer, home network, or competing jukebox program, such as Musicmatch Jukebox.

Fortunately, any audio that you can hear on your computer can be converted to another format. How easy that conversion will be depends on whether the files are copy-protected. If they are, you won't be able to convert them directly. However, you can use one of the indirect conversion methods described later in this article. If the files are not copy-protected and are in a format supported by your jukebox or audio-editing program, it's fairly straightforward to convert them to another format, and I'll cover that too.

Digital audio will continue to exist in multiple competing formats for the foreseeable future. While some specialized formats are necessary for certain applications, many of the current formats serve the same purpose. Some offer less restrictive Digital Rights Management (DRM, i.e., copy protection), some sound better at low bit rates, and some are better at streaming. But for the average user the main issues are compatibility with hardware and software, and restrictions imposed by DRM systems.

Formats: Lossless vs. Lossy

Lossless formats store digital audio with absolutely no loss of information. Some, like PCM, store just the raw audio data with no compression, while others like Apple Lossless and FLAC use lossless compression techniques to create files about half the size of files that use plain PCM.

Lossy formats like MP3, AAC, Ogg Vorbis, and WMA can achieve much larger reductions in file size than are possible with lossless compression. By discarding unnecessary and redundant information, lossy formats can squeeze an audio file to less than one tenth of its original size without losing much quality.

Table 1 lists several common formats for digital audio. You can identify the format of most audio files by the extension (the letters at the end of the file name). However, the same extension is sometimes used for entirely different formats, as is the case with Apple's lossless format and the AAC format used by the iTunes music store. In other cases, such as with AAC, different extensions are used, depending on which program created the file and whether the file is copy-protected.

Table 1. Common Digital Audio Formats (hear examples)

Format

Extensions

Notes

PCM (uncompressed)

wav, aiff

CD audio is PCM at a 44.1kHz sampling rate, 16-bit resolution, and two channels

MPEG Audio Layer-III (MP3)

mp3

An ISO standard for compressed audio; the most widely supported compressed format

mp3PRO

mp3

An extension to MPEG Audio Layer-III that provides higher quality at lower bit rates

MPEG AAC

aac, mp4, m4a

An ISO standard format that offers higher quality than MP3 at the same bit rate

AAC with Fairplay DRM

m4p

The copy-protected format for music purchased from Apple's iTunes Music Store

Ogg Vorbis

ogg

A high-quality open source format

Apple Lossless

m4a

A lossless format supported by iTunes

Windows Media Audio

wma

A proprietary format from Microsoft used by many online music stores

Real Audio

ra

A proprietary format from RealNetworks used primarily for streaming audio

Sound Quality

When you convert from one lossless format to another, or from a lossy format to a lossless one, you won't lose any quality. But when you convert from one lossy format to another you will lose a bit of information. That's because different encoding schemes throw away different parts of the signal. But that's part of the tradeoff. The same is true if you convert lossy files from one bit rate to another—you lose a little quality each time.

If you convert a lossless format to a lossy format, you will also lose information, but you can control the quality of the converted file by adjusting the bit rate and other settings. Lower bit rates result in smaller files with poorer sound quality, while higher bit rates result in better sound quality, but larger files.

With MP3, a bit rate of 192kbps should sound pretty good for all but the most demanding material. AAC can provide similar quality at 128kbps, which means the files will take up approximately 33% less space.

If you're converting AAC files encoded at 128kbps to MP3, set the bit rate for the MP3 files to 192kbps. Otherwise, you'll lose a lot of information because MP3 is less efficient than ACC and will not be able to store all the information at the same bit rate.

Which Format to Use?

Even with more sophisticated formats like AAC and WMA, many people prefer plain MP3. The reason is that MP3 is supported by the widest range of hardware and software, and that MP3 files can sound just as good as any of the competing formats.

If your hardware and software support it and you want smaller files without sacrificing quality, go with AAC or Ogg Vorbis. Lossless formats make sense only if you are starting with uncompressed audio and want to retain every bit of information. (For example, you might choose FLAC if you want to make backup copies of your CDs in half the space.)

Table 2 shows typical file sizes for a four-minute song in several formats.

Table 2. File Sizes for a 4-Minute Song in Different Formats

Format

Bit rate

File size

Songs/GB

Uncompressed Lossless (CD Audio)

1,411kbps

41.3MB

25

Lossless (e.g., FLAC)

1,411kbps

20.6MB

91

High-Quality MP3

192kbps

5.6MB

182

High-Quality AAC

128kbps

3.8MB

275

Three Conversion Methods

Figure 1 shows several methods of converting between digital audio formats. Audio capture should be the last resort, because it takes longer, and in some configurations the signal will be converted to analog and then back to digital, which means that more information will be lost and that noise can leak in.

Fig. 1: Audio Conversion Flowchart

Figure 1. Three methods for converting digital audio files to different formats.

1. Direct Conversion

Direct conversion is the simplest approach, because it converts one format to another without any intermediate steps. Direct conversion to MP3 and other popular formats may be accomplished with a jukebox program such as iTunes or Musicmatch Jukebox, or with an audio editing program such as Sound Forge or Peak.

When you convert a file to another format, the original file usually remains intact. Either delete it to save space, or move it to another location if you want to keep it as a backup. With iTunes, you'll also need to delete the duplicate entries from your music library.

iTunes

iTunes can only convert files that have been imported into its music library. To convert a file to another format in iTunes, first specify the new format and bit rate in the Preferences section.

To do that, select Edit (select iTunes on the Mac) → Preferences and click the Importing tab or button. For MP3, choose MP3 Encoder in the Import Using drop-down menu and choose the bit rate in the Setting menu:

iTunes Import Settings

Next, highlight one or more songs in your music library, then right-click and choose Convert Selection to MP3 from the pop-up menu. (If you had specified another format in the preferences screen, "MP3" would be replaced by that format on the pop-up menu.)

iTunes will automatically convert unprotected WMA files when you import them into its music library.

Musicmatch Jukebox

Musicmatch allows you to convert files to different formats without actually importing them into your music library. This is handy if you want to create MP3 files at several different bit rates without cluttering up your music library with duplicate entries.

To convert a file to another format in Musicmatch, select File → Convert Files. In the upper left pane, choose the folder that contains the files to be converted. In the lower left pane, highlight the files to convert. In the upper right pane, specify the destination directory (the folder where the converted files will be stored). Choose the new format from the Destination Data Type drop-down box. Click Start to begin the conversion and the converted files will be listed in the bottom right pane.

2. Burn and Rip

The most reliable way to convert copy-protected songs to plain MP3 (or any other format) is to use your jukebox program to burn them to a standard audio CD, and then rip the files from the CD to the format you want. The drawback of course, is the cost of the blank CDs and the time to burn and rip. (However, this problem is partially solved by using CD-RW discs, which can be erased and reused.) The advantage is that this approach should work every time.

Make sure you configure your jukebox program to burn audio-format CDs. (If you attempt to burn a copy-protected song directly to an MP3 CD, you'll get an error.) In most cases the ID3 tag information (song title, artist, genre, etc.) will be transferred to the new file, but in all cases you'll need to re-embed any album artwork.

3. Audio Capture

The last resort for converting copy-protected audio files to another format is to play them through any program that supports the format and record the audio via your sound card. (This is the same procedure used to record audio from an internet radio stream.) Once the audio is recorded, save it to the new format and import it into your jukebox program.

For this approach to work, you must have a full-duplex sound card, which means that the card can play and record at the same time. Most new sound cards are duplex, but many older sound cards (and many of those built into the motherboards of notebook computers) are not. In this case, use a streamripper program like Audio Hijack or Total Recorder to capture the audio (see Table 3).

Avoid running a cable from the Line Out jack of your sound card to its Line In jack. The sound quality will suffer more and some noise will be added, because the audio will be converted into an analog signal and then back to digital by your sound card before it is captured by your recording program.

Recording Audio

Following are the basic steps for recording audio through your sound card in Windows. Mac users can get more tips in Five Fun Ways to Play with Audio Hijack Pro.

Fig. 2: Volume Control Properties

Figure 2. In Windows the mixer device might be a sound card or a program like Total Recorder that emulates a sound card. The Properties screen of the Volume Control program (above) allows you to switch between mixing devices if you have more than one installed.

  1. In your recording program, create a new file and choose the sampling rate, resolution, and number of channels. For CD-quality audio, choose 44.1kHz, 16-bit, and stereo.

  2. Launch the system mixer (Volume Control program).

    To access the Windows system mixer, double-click the speaker icon in the system tray. If the icon is not visible, you can launch the Volume Control program via the Start Menu, by selecting Programs → Accessories → Entertainment → Volume Control.

    When you launch the Windows Volume Control program, it defaults to the Playback Control screen. To adjust recording levels, select Options → Properties → Recording (see Figure 2). The screen with the recording controls should now appear (see Figure 3).

  3. Select Digital, MP3/Wave, or Wave/Direct Sound as the source, depending on your sound card.

  4. Play a sample of what you are going to record and set the recording level while watching the meters in the recording program (or the system mixer). Adjust the level-control sliders so the peaks stay below the red area (see Figure 4).

  5. Queue up the source at the beginning of the track.

  6. Click the Record button in the recording program, then begin playing the source.

  7. When the source is finished playing, click the Stop button in the recording program.

  8. Trim off any silence at the beginning or end of the track.

  9. Save the audio to your hard disk in the desired format.

Fig. 3: Windows Recording Controls

Figure 3. The Recording Control screen of the Windows Volume Control program allows you to select the audio source to record. To record audio from a jukebox program or internet radio stream, use Digital, MP3/Wave, or Wave/Direct Sound.

Fig. 4: Setting Proper Levels

Figure 4. The level in the meter on the left is too low, with the peaks around –17dB. The level on the right is too high, with the peaks at 0dB, and clipping in both channels. The meter in the center shows optimum levels with peaks around –2dB.

Utility Programs

Table 3 lists several utility programs for capturing audio and converting files to different formats. Audio Hijack and Total Recorder are full-featured recording programs. BarbaBatch is focused on converting digital audio into a variety of formats. Wisecroft Ripper converts Real Audio to PCM WAV.

Table 3. Audio Capture and Conversion Utilities

Program

Website

Notes

Audio Hijack (Mac)

www.rogueamoeba.com

Captures audio from any source

BarbaBatch (Mac)

www.audioease.com

Supports Real Audio, MP3, and other common formats

Total Recorder (Windows)

www.highcriteria.com

Captures audio from any source

Wisecroft Ripper (Windows)

www.wisecroft.com

Converts Real Audio to WAV

Legalities of Format Conversion

If you plan to convert files from a copy-protected format to an unprotected format, you have legal considerations in addition to technical considerations to contend with.

If you legally purchased the song, the Doctrine of Fair Use (a part of U.S. copyright law) allows you to convert the song to another format as long as you don't share it with other people. The Digital Millennium Copyright Act (DCMA) [PDF file] prohibits distribution of software designed to circumvent copy-protection measures, but does not explicitly prevent circumvention by individual users for Fair Use purposes.

Another issue is that the usage agreements of many online music stores appear to prohibit you from exercising your rights under Fair Use. The usage terms at the iTunes Music Store appear to allow conversion of copy-protected files to another format as long as it's for your own use, while the terms of stores that offer music in copy-protected WMA format (which includes most of the stores that sell major-label music) appear to specifically prohibit it.

While it is not against the law to convert copy-protected files you own to other formats, by some interpretations of the DMCA I would be violating the law simply by telling you how to do it. But if you own the original file and use the converted version solely for personal enjoyment, it's hard to see how you'd be doing any harm to the copyright owner. On the other hand, if you were to convert (or simply copy) copyrighted music and give it to someone else—for example, you convert a copy-protected song from an online music store to an unprotected MP3 file and give it to a friend—you would be committing copyright infringement.

Audio Examples

Following is a 30-second clip of Beethoven's Ninth Symphony recorded in several different formats to help you compare the effects of format conversion and data compression. [Ed. Note: Because there is no universal audio player, some of the links below may trigger a "missing plug-in" error message. QuickTime users can add Ogg Vorbis support with the free Xiph QuickTime Components and WMA support (for Macs) with Flip4Mac. Another way to hear all the files is to right- or Control-click the links to download them, then use a combination of stand-alone players. The open source VLC should handle everything but Real Audio. You can get an ad-free version of RealPlayer on the BBC site.]


Return to the digitalmedia.oreilly.com