—> To Continue with Chapter 3

Phasors

In Chapter 1 we talked about the basic atoms of sound — the sinewave, or the function that describes the sound generated by a
vibrating tuning fork. In this chapter we're talking a lot about the frequency domain. If you remember, our basic units, sine waves, only had two parameters: amplitude and frequency. It turns out that these little dull and boring sine waves are going to give us the fundamental tool for the analysis and description of sound, and especially the digital manipulation of sound. That's the frequency domain, a place where lots of little sinewaves are our best friends.

But before we go too far, it's important to fully understand what a sinewave is, and it's also wonderful to know that we can make these simple little curves ridiculously complicated too. Nonetheless, it's useful to have another model for generating these functions. That model is called a phasor, just like the Star Trek handgun.


Description of a phasor

There is no permission for this.
There is no permission for this.

Think of a bicycle wheel suspended at its hub. We're going to paint one of the spokes a bright red and at the end of the spoke we'll put a red arrow. We now put some axes around the wheel — the x-axis going horizontally through the hub and the y-axis going vertically. We'll be interested in the height of the arrowhead relative to the x-axis as the wheel — our phasor — spins around counterclockwise.


Sinewaves and phasors

As the sinewave moves forward in time, the arrow goes around the circle at the same rate. The height of the arrow (that is, how far it is above or below the x-axis) as it spins around in a circle, is described by the sinewave.

In other words, if we trace the arrows location on the circle (from 0 to 2) and measure the height of the arrow on the y-axis as our phasor goes around the circle, the resulting curve is a sinewave!

Thanks to: George Watson, Dept. of Physics & Astronomy |University of Delaware, ghw@udel.edu, for this animation.

As time goes on the phasor goes round and round. At each instant we measure the height of the dot over the x-axis. Let's do a small example first. Suppose the wheel is spinning at a rate of one revolution per second. This is its frequency (and remember, this means that the period is 1 second/revolution). This is the same as saying that it spins at a rate of 360 degrees per second, or better yet, 2\2 radians per second — if we're going to be mathematicians, then we have to measure angles in terms of radians. So 2 radians per second is the angular velocity of the phasor.

This means that after .25 seconds the phasor has gone /2 radians (90 degrees), and after .5 seconds it's gone radians or 180 degrees, etc. So, we can describe the amount of angle that the phasor has gone round at time t as a function, which we call theta(t) or (t), and we see that:


Now, let's look at the function given by the height of the arrow as time goes on. The first thing that we need to remember is a little
trigonometry.

The sine and cosine of an angle are measured using a right triangle. For our right triangle below, the sine of , written sin() is given by the equation



and notice that this means that



We'll make a lot of use of this in a minute, because in this picture, a is the height of our triangle.


Similarly, the
cosine, written is:



and:



This will come in handy too.


Now back to our phasor. We're interested in measuring the height at time
t, which we'll denote as h(t). At time t, the phasor's arrow is making an angle of (t) with the x-axis. Our basic phasor has a radius of 1, so we get the following relation:



and we get this nice graph of a function which is our favorite old sine curve. This is a basic
sinusoid.

Applet that traces out a sine curve as the phasor wraps around.

Installed


Now, how could we change this curve? Well, we could change the amplitude — this is the same as changing the length of our arrow on the phasor. We'll keep the frequency the same, and let's make the radius of our phasor equal to 3. Then we get:



so



and we get this nice curve, which is another kind of sinusoid (bigger!).


Now, let's start messing with the frequency, which is the rate of revolution of the phasor. Let's ramp it up a notch and instead, start spinning at a rate of 5 revolutions per second! So, now


This is easy to see since after one second we will have gone 5 revolutions which is a total of
10\ radians. Let's suppose that the radius of the phasor is 3. Again, at each moment we measure the height of our arrow, which we call h(t) and we get


or



and we get this lovely and talented sinusoid:


In general, if our phasor was moving at a frequency of revolutions per second, and had a radius of A, then plotting the height of the phasor is the same as graphing the sinusoid


Now we're almost done, but there is one last thing we could vary! We could change the place where we start our phasor spinning. For example, we could start the phasor moving at a rate of 5 revolutions per second, with a radius of 3, but start the phasor at an angle of /4 radians,


Now, what kind of function would this be? Well, at time
t=0 we want to be taking the measurement when the phasor is at an angle of /4, but beyond that all is as before. So the function that we are graphing is simply the same as the one above, but with a phase shift of /4. The corresponding sinusoid is this:


and our most general sinusoid of amplitude
A, frequency and phase shift has the form


A particularly interesting example is what happens when we take the phase shift equal to
90 degrees or /2 radians. Let's make it nice and simple, equal to one revolution per second and amplitude equal to 1 as well. Then we get our basic sinusoid, but shifted ahead /2. Does this look familiar? This is the graph of the cosine function!

You can do some checking on your own and see that this is also the graph that you would get if you plotted the displacement of the arrow from the y-axis. So, we now know that a cosine is a phase-shifted sine!

Adding Phasors

Fourier's Theorem (we'll get to that later, we just wanted to sneak this important name in early!) tells us that any periodic function can be expressed as a sum (possibly with an infinite number of terms!) of sinusoids. Remember, a periodic function is any function that looks like the infinite repetition of some fixed pattern. The length of that basic pattern is called the period of the function.We've seen a lot of examples of these in Chapter 1.

In particular, if the function has period T (don't ask us why we use T to represent the period, that's just the way it is — it probably came from "time" of revolution) then this sum looks like:

If T is the period of our periodic function, then we now know that its frequency is 1/T — this is also called the fundamental (frequency) of the periodic function, and now we see that all other frequencies that occur (called the partials) are simply integer multiples of the fundamental.

If you read other books on acoustics and DSP, you will find that partials are sometimes called overtones, from an old German word (übertonen), and harmonics. There's often confusion about whether the first overtone is the second partial, etc. So, to be specific, and also to be more in keeping with modern terminology, we're going to always call the first partial the one with the frequency of the fundamental.

Example: Suppose we have a
triangle wave that repeats every once every 1/100 seconds. Then the corresponding fundamental frequency is 100 Hz (it repeats 100 times per second). Triangle waves only contain partials at odd multiples of the fundamental (the even multiples have no energy — in fact, this is generally true of waveshapes that have the "odd" symmetry like the triangle wave).Click on the applet below and see the triangle wave built by adding one partial after another!

Building a triangle wave partial by partial.


This adding up of partials to make a
complex waveform might make sense acoustically, but in order to really understand how to add phasors, from a mathematical standpoint, we first need to understand how to add vectors, or arrows.

How should we define an
arithmetic of arrows? It sounds funny, but in fact it's a pretty natural generalization of what we already know about adding regular old numbers. Remember your old "number line" model of adding numbers? When we add a negative number, we go backwards on the line. When we add a positive number, we go forward.

Our regular old numbers can be thought of as arrows on the number line. Adding any two numbers then simply means taking the two corresponding arrows and placing them one after another, tail to tail. The sum is then the arrow from the origin pointing to the place where "adding" the two arrows landed you.

Really what we are doing here is thinking of numbers as vectors. They have a magnitude (length) and a direction (in this case, positive or negative, or better yet, 0 radians or radians).

Now to add phasors we need to enlarge our world view and allow our arrows to not just get 2 directions, but instead, a whole 2 radians worth of directions! In other words, we allow our arrows to point anywhere in the plane! (But remember, it is against Federal Regulations to take arrows on a plane.) We add then just as before: place them tip to tail, and draw an arrow from the origin to the final destination.

(If you want to impress your friends, tell them that you've just learned how to do vector arithmetic! They will think you very cool. That's why they're avoiding you — really!)

So, to recap: to add phasors we do the following: at each instant as our phasors are spinning around we add the two arrows. In this way get a new arrow spinning around (the sum) at some frequency — a new phasor. Now it's easy to see that the sum of two phasors of the same frequency yields a new phasor of the same frequency —so for example it is easy to see that the sum of a cosine and sine of the same frequency is simple a phase-shifted sine of the same frequency with a new amplitude given by the square-root of the sum of squares of the two original phasors. That's just the Pythagorean Theorem!

Sampling and Fourier Expansion

There is no permission for this.

The decomposition of a complex waveform into its component phasors (which is pretty much the same as saying the decomposition of an acoustic waveform into its component partials) is called Fourier expansion.

In practice, the main thing that happens is that analog waveforms are sampled, creating a time domain representation inside the computer. These samples are then converted (using what is called a Fast Fourier Transform, or FFT) into what are called Fourier coefficients.

FT of sampled phasors exp(2*j**x/64), x=1,1.01, 1.02,...,1.90,2
Let's play a game: A phasor is set spinning in a dark room. We want you to determine its
Fourier expansion. What you are allowed to do is take as many pictures as you like with a flash camera — so at each instant you can record the position of the phasor. The goal is to do this with as few pictures (samples) as possible. Also, just to give you a fighting chance, we'll tell you what the fundamental and the highest frequency which occurs (some finite number).

Here's a
fact that will help a great deal: If the highest frequency is B times the fundamental, then you only need 2B+1 samples to determine the Fourier coefficients. Easy to see that you should need at least 2B, since you are trying to get 2B pieces of information (B amplitudes and B2 phase shifts)
Figure.x Aliasing, foldover.

This is a phenonemon that happens when we try to sample a frequency which is more than half the sampling rate, or the Nyquist frequency. As the frequency we want to sample gets higher than half the sampling rate, we start "undersampling" and get unwanted, lower frequencies artifacts. We'll learn lots more about it in a later chapter


Figure .x FFT plot of a gamelan instrument.

This picture is a common way to show timbral information, especially the way that harmonics add up to produce a waveform. However, it can be slightly confusing. By running an FFT (Fast Fourier Transform) on a small time slice of the sound, the algorithm gives us the energy in various frequency bins The x-axis (bottom axis) shows the bin numbers. The y-axis shows the strength (energy) of each partial.

The slightly strange thing to keep in mind about these bins is that they are not based on the frequency of the sound itself, but on the sampling rate. In other words, the bins evenly divide the sampling frequency (linearly, not exponentially, which is a problem!). Also, this plot just shows a short fraction of time of the sound — to make it time-variant, we need a waterfall 3D plot (we've seen a bunch of these in this book). Although theoretically, we could use this information in its raw form to make a lovely, synthetic gamelan sound, the complexity and idiosyncracies of the FFT itself make this a bit difficult (unless we simply use the data from the original, but that's cheating...).

The picture below shows a better graphical representation of sound in the frequency domain. Time is running from front to back, height is energy, and the x-axis is frequency. This picture also takes the essentially linear FFT, and shows us an exponential image of it, so that most of the "action" happens in the lower 2k, which is correct. (Remember that the FFT divides the frequency spectrum into linear, equal divisions, which is not really accurately how we perceive sound — it's often better to graph this exponentially so that there's not as much wasted space "up top").

Note that the waterfall plot below is stereo, and each channel of sound has its own slightly different timbre!


—> To Continue with Chapter 3

<— Back to 3.1

<— To Table of Contents