<- Back to Main

Assignment 06 - DUE Friday, April 18th





Reading Assignment:

Wikipedia: Fourier Transforms

Introduction

I'm sure you've encountered Fourier Transforms in a math or physics class before. Here, we will find the "Discrete" Fourier Transform or "spectrum" of a wave form. In class we used a microphone to take a series of measurements of some noise we made with our harmonica and tuning fork. The microphone takes measurements at rate of 44,100 samples per second. The computer puts these measurements in to a .WAV audio file. We will use IDL to read the .WAV file and calculate the sound's frequency spectrum.

The Assignment:

For the following problems, download these files so we have something to play with:

WAVE files:
fork.wav - The pure tone of the Tuning Fork.
harmonicafork.wav - The sound of the tuning fork mixed with James' masterful harmonica playing.

1) Create the Fourier Transform

-First we read the fork.wav file into IDL using READ_WAV().

-Then take the FFT() of the data you just read out of the wave file.

This gives us the discrete 'Fast Fourier Transform'. This is what our waveform looks like in FREQUENCY space. (Originally the waveform is in TIME space.)

-Now SHIFT() the data by 1/2 of the number of elements in the data.

We have to shift the FFT because of the strange way the transform is calculated. At first the 0 frequency position of the plot is on the far left hand side, the maximum positive frequency is in the center of the plot, followed by the most negative, and ending with the smallest negative frequency in the spectrum or FFT.

< 0.0 hz --- High Freq | Most Negative Freq --- -0.0001 hz >

(-0.0001 is arbitrary)

-Finally take the ABS() of the data and square it.

This gives us the Power Spectrum. Since our audio program probably calibrates the WAV file in decibles, this would mean our power spectrum has units of decibles2.

You should plot the spectrum at each stage of the processing to make sure that it looks like you expect.

2) Generate the Frequency Axis Array

-Now that we have the data values of the FFT, we need to generate the X-axis. Use your MYFILLARR() program to do this. For the MIN input, use -FREQUENCY/2. and for the MAX use +FREQUENCY/2., where the FREQUENCY is 44,100 Hz, the sampling frequency Dustin used to create the audio file.

We want the range of the FFT to be +- the Nyquist frequency (Nyquist Freq = Sampling Freq / 2). Set the BIN to the range of values divided by the number of elements of the data file. We want the X-axis to have the same number of elements as the FFT.

-Now plot your FFT against the X-array you just made, using a proper title, and titles for the axes. The x-axis will be in KHz, and the y-axis in "Power".

-Plot a FFT for both data files in the same Postscript (PS) file. Set the !p.multi environment variable to [0,1,2]. ALSO, when you plot your second FFT, use the plot keyword, /noerase, otherwise plotting the second time will erase your previous plot!

As before, use PSOPEN() and PSCLOSE() to make your PS file.

To Turn In:

-On your bio page, post the PS file you made and the program you wrote to generate it.

Your finished PS file should look something like this:



Notice the two large inner peaks in the bottom spectrum. These occur at about 500 Hz, and correspond to the frequency printed on the tuning fork, 512 Hz. This is a good sanity check to verify that we probably have the correct frequency axis.

HINTS:

Refer to the notes you took in class!
Use the IDL> DOC,'procname' procedure to look up how to use a procedure. For native IDL procedures (such as read_wav and fft) use ?read_wav and ?fft.



Update: Paul Higgins - April 9, 2008 - UG Astro, Department of Astronomy, University of California at Berkeley