Saturday, November 7, 2009

Fourier analysis 2 - More complicated sound waves

I imagine the discussion in the previous entry seems pretty boring. It was really easy to tell apart the A note from the white noise, both by sound and by looking at the graphical representation. Things get more complicated however when we add more notes to make a chord or a complicated piece of music. For example, a simple A chord consists of three notes - A, C# and E. The nearest C# to the standard A has a frequency of 523.25 Hz while the nearest E has a frequency of 659.26. Here's what that sounds like on my guitar (it's sort of fun posting videos of my guitar online), followed by the graphical image:

One can still see the oscillatory behavior, but things aren't quite as clean as they were when I was plotting just the simple A note.

Now, what happens if I play a full A chord by adding A notes from the next two octaves up and another C# as well?

You can still see a few clear features, but overall it doesn't look nearly as obvious that this is an actual chord. In reality, no sound wave is perfectly free of noise either. We are all familiar with static in our speakers and acoustic reflections tend to add noise to the wave as well. In general, external sources of static add white noise on top of the underlying wave. In such a situation, it can be impossible to see the wave underneath the noise just by eye.

This is where Fourier analysis comes in. Fourier analysis is a mathematical method that can decompose signals like the ones shown in the various pictures into their constituent waves. By Fourier analyzing a pulse, we can find out how much of each pulse is contributed by a wave of a particular frequency. For example, returning to the simple A note, the entire pulse is a wave of 440 Hz. Therefore, the Fourier transform of that plot should provide us with a peak at 440 Hz, and nothing else. Here's what the Fourier transform of the A note looks like:

The Fourier transform has picked out the signal at 440 Hz, and shown that it is the only component there. What about white noise, where there is no dominant frequency component? Fourier analysis can find that as well.

And finally, where Fourier analysis really shines is when the signal is so complicated that one couldn't possibly tell apart all its constituents by eye. For example, look at the Fourier decomposition of the full A chord - all of the 6 notes are clearly broken out in the decomposition and we can understand exactly what went into the making of that sound.

I have one last example, just because I think this is so cool. I made a signal of 12 semi-random frequencies, with a little white noise added. The first plot is what they look like in the time domain (i.e. when you plot the amplitude of the sound as a function of time). There's no real pattern there that I can see. But when I plot the Fourier transform, there they all are. It's like magic. But it's not, it's just math, and I'll try to explain it qualitatively in the next post.


  1. Hi!

    Sorry for leaving a comment in an old post (I hope you see it!). I have a question:

    When you obtain the Fourier trasform of a function, even a real valued one, you get complex values, did you use only the real part of the transform or something like that to plot the power at each freq?

    Thanks! (Very cool blog, by the way, heh).

  2. Hi Aldo,
    Sorry for the delayed response, but when I plot the Fourier transform, I'm really plotting the amplitude squared to get the power, so multiply the fourier transform by its complex conjugate and that's what is shown in the figure.

  3. Q1: How do you feed the sound signals into your mathematical Fourier Transform Program?
    Q2: What Fourier transform program do you use to Break the signal?
    Q3. Is this program available?

  4. I know this is a post is 8-9 years old. Just wanted to say thanks for a well written and informative post :).

    I've been trying to wrap my head around the Fourier Transform and too many authors excite themselves with their own complexity so much to the point that I completely forget the topic of the article (-_-).
    But tis is exactly what I've been looking for. Thanks again :)