Overview
For this project, you will write a program that processes audio files based on
user input. You might be familiar with audio editing tools such as SoundForge
or Cool Edit Pro. The program you will write will have some of the same
functionality, only using text input commands instead of a graphical interface.
Background
This project is based around the manipulation of audio data inside a program.
As you probably known from physics classes, sound travels as a wave. We can
visualize this wave as something like a sine function.
Here is an image of several waves with different frequencies. Each is what
is called a pure tone. At the top, the frequency is lower, making the equivalent
note lower in pitch. The pitch of the notes increases as the waves go down
the page. Of course, the representation of real sounds are more complex. Real
sounds have chaotic looking wave forms because much more is going on than
just a single pure tone, as shown.
1
, Of course, computers can’t deal with with nice, smooth waves. To record or
manipulate a sound in a computer, you need to turn the wave into a series of
values. This is done with a process called sampling. Sampling means that the
wave is chopped up into lots of equal sized time divisions. For each division,
we pick one value to represent the wave at that point. In this way, we can
approximate the wave with a series of numbers. Below is a picture showing a
tiny section of a wave form. Each small blue box represents the sample value of
that wave.
With CD quality sound, there are 44,100 samples per second. That’s why
CD audio takes up so much space. Every single second has 44,100 numbers
giving the height of various parts of a wave. The StdAudio library developed
by two Princeton professors lets us easily manipulate CD quality audio, but not
MP3’s. MP3’s use a number of mathematical and psycho-acoustic techniques
to use a lot fewer numbers to represent the waves. So, we’re going to stick with
CD quality audio, stored in the form of .wav files on your computer.
The StdAudio library provides a very easy way to load and save .wav files.
When they are loaded, they will be represented as an array of double values.
Each value represents one sample. So, for a song that is 3:56 long, the array will
contain 10,407,600 double values. For this reason, we are going to stick to small
.wav files. In the format used by StdAudio, each value in the array is between
-1.0 and 1.0. Thus, a maximum volume sound has peaks at 1.0 and -1.0. A
completely silent sound represented by samples at 0.
2