The Drawing Board

  by Logan Everett (E-mail Me)

#2 - Working with Sound Files


The latest Internet craze appears to be music. The MP3 file format is responsible. Sure, anybody can download a few pop songs and listen to them in WinAmp, but what if you want to do more. Ever wanted to make a CD with your collection of MP3 files? Ever wonder what the heck an MP3 is? Well, then you've found the right place.

First off, there are 2 types of sound formats we will talk about, but both work in generally the same way. To create a digital sound, a real sound is recorded. Sounds are defined as a wave of particles. The computer takes the position of this wave, called a Sample, a certain number of times every second. It then places these samples in chronological order on a Wave Scale, which determines such qualities as Pitch and Volume. The computer then reads the samples and uses a sound card to generate a similar sound based on the data. This digital version is not perfect, mind you, but it is the most advanced and accurate method to date. These are the 2 types of sound file formats we will talk about:

  • Wave Files (.wav): These used to be the most popular sound files. This format is still used to play shorter sound clips. Basically, a .wav file contains each sample from start to finish so it is very simple for the computer to read through each one and generate the sound accordingly. However, this can produce some very large files, especially when you're talking about a 3 or 4 minute song.
  • MPEG Layer-3 Encoded Files (.mp3): The new revolution in music, this format is usually used for single songs. This format is based around an algorithm, or a set of instructions that are repeated, that takes the original wave pattern of the sound and transforms the data into smaller pieces. The algorithm can then be reversed, turning the data back into the original wave pattern. I can't explain exactly how this particular algorithm works, as I don't fully understand it myself. I do know that this method is similar to the way .zip files work. This method creates smaller files, perfect for downloading. However, the computer has to work fast enough to apply the decoding algorithm as it is playing the file. Note: Algorithms that are used to compress data, as in .zip and .mp3 files, are also called Codecs which stands for Coder/Decoder.
With this in mind, it is fair to say that Wave Files are good when you don't care about file size (or it isn't the most important issue) and you want to play it with as little work for the CPU as possible. MPEG Layer-3 Encoded Files are good when file size is an issue (especially when downloading files) and you can afford to put a little strain on the CPU while playing.

While explaining these formats I mentioned something called a Wave Scale. This term refers to the way the bits in the file are arranged on a scale (measuring pitch and volume) as the computer plays through them. Pure musical notes would create a smooth curve, but keep in mind that a perfect curve is not possible in digital music. For a visual representation, open a Wave File in a sound editing program (even Sound Recorder will do) and play it. Some programs display sound slightly differently, but all hold to the same general idea.

Both formats have some common properties. Both have a Playback Rate, measured in Kilohertz (Khz) and a Bits per Sample. The Playback Rate tells the computer how many samples to play each second. By changing this value, you change the amount of space between each peak in the Sound Wave (the peaks being the points on the curve that are farthest away from the central horizontal line of the wave scale, once again check out a sound program to see what I mean). This space is measured in Kilohertz. When recording a sound, Playback Rate is instead called Sampling Rate.

Bits per Sample tells the computer how many bits to assign to each sample (Duh). Okay, to clarify that, a bit is a single value that can either be a 0 or a 1. Obviously, one bit is not enough to define a sample as you could only have "sound" and "silent". However, if we assign 4 bits to each sample, than different combinations of 1's and 0's can mean different things. So, the more bits we add, the more levels of accuracy we have between "loudest" and "no sound at all". Increasing either Playback Rate or Bits per Sample will directly increase the quality of the sound and the size of the file because we can have more detailed data and pack more tightly into a given amount of time.

Also, both formats have channels. Each channel has it's own wave pattern, and all channels are played simultaneously. Each channel corresponds to one or more speakers. If a sound file has one channel we call it "Mono", and all speakers play the same wave pattern. If a sound file has two channels we call it "Stereo" and one wave pattern is played through the left speaker(s), while the other plays through the right speaker(s). Your home sound system probably has a button for "Mono" or "Stereo". Stereo is the most commom, but more channels are possible with the presence of surround sound systems. In such a case, you might have 5 channels: Left Front, Left Back, Right Front, Right Back, Sub-Woofer, each one corresponding to it's given speaker.

Recording your own sounds can be fun, and any sound editing program will work. When recording with a single microphone, ALWAYS record to one channel (Mono). Otherwise you are just creating two channels with the exact same data and this will double the size of the file! More advanced programs may allow you to split the channel later, by moving some pieces of the Wave Pattern to a new channel, but this is still done after recording. The Playback Rate and Bits per Sample is up to you, just remember that the higher the number, the better the quality, and the larger the file. Most music is recorded at 44.1Khz (This is CD quality, by the way) and 16 bits per sample.

Recently I made my first audio CD from .mp3 songs I had downloaded. With the right software, this can be a simple process. First, I downloaded Goldwave (click the link to go to the creator's website). This program is amazing. It allows you to open, edit, and save in all the major sound formats, including .wav and .mp3! I also used Adaptec Easy CD Creator 3.5, which seems to come with every CD-R around. First, I had to turn all the .mp3 files into .wav files. This is done because a CD is not encoded like an .mp3 file, but rather, the samples are laid out like in a .wav file. I also used goldwave to give each sound the proper Playback Rate for a CD (44.1Khz) and to adjust the volume on some of the quieter tracks so that the entire CD would play at approximately the same volume. Volume is adjusted by moving all the samples farther away from the center line of the wave scale. Then I simply used Easy CD Creator to select all the .wav files, put them in order, and move them to a CD. It was that easy!

One final note on Playback Rates. If you open a sound and simply change the playback rate, the sound will play at the wrong speed and pitch. Goldwave, and most other programs have a command called "Resample" which basicly recreates the entire set of samples at the new Rate. It may have to add samples and guess at their appropriate position or it may need to cut some samples out, in order to keep the proper sound. This technique can slightly change the sound, so only do it if it is absolutely neccesary. Oh yeah, and you will need a CD-R or CD-RW to make your own CD's. That is it's own topic, however. Please, E-mail Me and tell me what you want to hear about in this editorial.


Page Updated: 1/4/00