An interesting application of the Fourier transform to audio is detecting specific frequencies or tones. You might imagine building a device which uses a sequence of tones as a form of input. For example a door lock that only opens when you whistle the right tune. To demonstrate this, let's make the hardware built in this guide respond to specific sequence of tones.
 First we need to understand what frequencies make up the sequence of tones to detect. The spectrogram tool from the previous page is the perfect tool for this analysis.For example the image on the left is a spectrogram of me whistling up and down slowly. Read the graph starting from the bottom and going up so you see the slow rise and fall in frequencies as I whistle.If I wanted to detect this sequence I just need to look for a series of strong intensities from the FFT output at the rising and falling frequencies of the whistle. Taking things a step further, the image on the left represents a spectrogram of 5 notes being played from an instrument. Again, read the graph from the bottom up. Low frequencies are to the left and high frequencies are to the right. From analyzing the spectrogram I can see the notes I want to detect are highest in intensity between these frequencies: Note 1: 1,723 to 1,758 hz Note 2: 1,934 to 1,969 hz Note 3: 1,512 to 1,546 hz Note 4: 738 to 773 hz Note 5: 1,125 to 1,160 hz The toneinput sketch in the code is a program which looks for this sequence of notes and flashes the LEDs when it detects them being played in order. Look at the code's toneLoop() function to see how it uses an array of tone frequencies, count of current position in the tone frequency array, and threshold of intensity to detect the sequence.
Can you guess the tune being played from looking at the spectrogram above?

Here's a video below of the tone sequence detection with the answer. As you hear the tones played, look at the spectrogram to see how each note relates to output on the graph.
Temporarily unable to load embedded content: