The Fourier Transform and the Spectrum

Sine waves combining to form a violin waveform
Sine waves combining to form a violin waveform.

In What Makes a Musical Sound Part 2, I talked about the spectrum, which shows what frequencies are present in a sound.  In this explicative post, I’ll go into more detail about how we obtain the spectrum, and about what it means when we say a sound is made up of different frequencies.

Sine Waves

But first – what does it mean when a sound has a frequency of, say, 784 Hz?  Well, it means that its waveform is periodic and repeats itself 784 times per second.  But this tells us nothing about the actual shape of the waveform.  It could look like this:

Waveform of square wave

Or this:

Waveform of sawtooth wave

Or this:

Waveform of sine wave

In each of the above cases, the highlighted part repeats itself every 1/784th of a second.

Which of the above is the most natural-looking wave?  You would probably have chosen the third case, since it’s nice and smooth.  This is a sine wave, and we see it often in nature.  For example, if we were to suspend a weight on a spring, and then pull it down and release, the weight would oscillate up and down, and its height as a function of time would trace out a sine wave:

Harmonic Oscillation HD by Alexander C.

Or, if we had a spinning wheel, and focus on a point on the circumference of the wheel, then the vertical position of that point as a function of time would trace out a sine wave:

Animation of sine wave traced out by a point on a spinning wheel
Sine wave traced out by a point on a spinning wheel. Sin Drawing Process by Malter / CC BY-SA 3.0.

What about sound waves?  Consider the tuning fork, which is an instrument used to provide a reference pitch (because its natural vibrating frequency is not too much affected by things like temperature and humidity, unlike other instruments).  You use a tuning fork by striking it against an object, usually one that isn’t too hard (such as your wrist).  This sets its split ends, or tines, vibrating.  If we followed the position of the tip of one of the tines, it would trace out a sine wave as a function of time.  The tines in turn push on the surrounding air particles, causing them to also vibrate sinusoidally (in a sine-like manner).  You can see a tuning fork vibrating in this slow-motion video:

Tuning Fork Vibration by Dan Russell.

However, most other musical sounds are more complex.  A violin string vibrates in a more complicated pattern than a simple sine wave, and so in turn do the air particles which are set in motion by the instrument.  Have a look at the following waveform, which is a small fragment of a violin note playing at 784 Hz (the note G5).  The segment marked by the braces repeats itself every 1/784th of a second.

Segment of waveform of violin playing G5
Segment of waveform of violin playing G5
Sounds from the Philharmonia Orchestra’s free sound samples / CC BY-SA 3.0.

Click to expand: Sine waves and outer space

Real musical instruments don’t vibrate sinusoidally.  But with the advent of electronic music at the turn of the 19th century, we began to be able to create electronically-generated pure sine tones.  Because they sound unfamiliar, they’re often used to produce an otherworldly mood.  One of my favourite examples is the original Doctor Who theme tune.  Though the theme was composed by Ron Grainer, it was the electronic music arrangement by Delia Derbyshire that gave it its weird alien-like quality.  You can hear the sine wave, generated by electronic oscillators, in the swooping melody.  Some viewers were allegedly terrified by this music when it played on TV in 1963!

The Fourier Theorem: Everything is Made of Sine Waves

So why are sine waves useful to us?  It turns out that there is a mathematical theorem called the Fourier theorem, which says that you can take any periodic waveform and break it down into a whole bunch of sine waves of different frequencies.  Conversely, if you take the correct amounts of sine waves of each frequency, you can add them up to get the original waveform.  In a sense, sine waves act like building blocks from which you can get any complicated periodic waveform you want. 

Let’s go back to the spectrum of a sound.  If the spectrum has a peak at, say, 1568 Hz, it means that when you break the sound down into sine waves, there is a particularly large contribution from the sine wave that has a frequency of 1568 Hz.

Spectrum of violin G5 note
Spectrum of violin G5 note

Now have a look at the spectrum of the above violin note.  The spectrum’s distinct peaks indicate the fundamental frequency of 784 Hz and its harmonics.  The following image shows the sine waves that have frequencies and amplitudes corresponding to the first 7 peaks (each one has been shifted along the x-axis by some amount, to ensure that they add up correctly later).  Notice that the higher-frequency sine waves have lower amplitudes or heights, corresponding to the diminishing height of the spectral peaks at higher frequencies.

The first 7 sine waves that make up the Fourier transform of the violin waveform
The first 7 sine waves that make up the Fourier transform of the violin waveform

These first few harmonics are the strongest components that make up the violin sound.  In the following animation, the red line shows the resulting sum when we start from the first sine wave (with f = 784 Hz), and successively add in the sine waves corresponding to the next 9 harmonics.  As we add each successive sine wave, the sum approaches the original signal (in blue) more and more closely.  You can also hear the resulting sound, which starts from a pure sinusoidal tone at the fundamental frequency, and sounds more and more like a violin as more harmonics are added in.

 

Click to expand: More details

The reason that we don’t get a perfect reproduction of the original signal is twofold: first, we would have to add more harmonics than just the first 10 peaks (an infinite number in theory, but since this is a digital sound sampled at discrete time steps, we’re limited by the finite number of samples in the segment).  Secondly, the violin sound (being a real sound, rather than a computer-generated one) is not perfectly periodic – though it repeats itself 4 times in the pictured segment, each time is just very slightly different from the last.  To capture these tiny differences, we would need to include, in the Fourier analysis, sine waves with frequencies that are between the harmonic peaks in the spectrum.  Which frequencies?  The sine waves that we use would be the ones who complete an integer number of oscillations within the time frame of the sound segment.

Jagged Waveforms

Even waveforms that don’t look smooth can be broken down into sinusoidal components.  Take the sawtooth wave that we saw above, for instance.  This is a jagged periodic wave, so-named because its shape resembles the edge of a saw:

Waveform of sawtooth wave

Spectrum of sawtooth wave

This computer-generated sawtooth wave has a frequency of 784 Hz, equal to that of our violin note above, but its spectrum shows high-frequency peaks that are much stronger.  This animation shows how the sawtooth waveform is approximated by the sine waves corresponding to the fundamental and first 49 harmonics:

Animation: Adding sine waves to form a sawtooth wave
Adding sine waves to form a sawtooth wave. Synthesis Sawtooth by LucasVB / CC BY-SA 3.0.

While the sum approaches the sawtooth shape very closely, we don’t quite get there – since the sine waves are smooth, they have a lot of trouble forming the sharp corners of the sawtooth.  In order to get back the sawtooth wave exactly, we would need to add an infinite number of sine waves, of increasingly higher frequencies.  Unlike the natural sounds of the flute and violin, the sawtooth’s harmonics don’t die out quickly as we get to higher and higher frequencies.  The strength of its high harmonics gives the sawtooth a very abrasive sound, though you can still hear its distinct G pitch.  Generally, waveforms with sharp corners (not often seen in physical instruments) have lots of high harmonics, and sound harsh.

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz