12 Distinguishing between claps and other noises

We want our simulated Clapper to respond to two claps separated by about one-half of a second. How do we distinguish between claps and other noises? The two plots below of two claps and two whistles look quite similar.

Clapping:

Whistling:

12.1 Bandpass filtering

It turns out that the sound made by clapping tends to fall within the range of frequencies of 2200 Hertz to 2800 Hertz. We can filter the audio signal to attenuate frequencies outside of a range of frequencies using a techinque called bandpass filtering. If you take a signal processing course later in your academic career you will learn the mathematics behind bandpass filtering.

MATLAB can perform bandpass filtering with a single function call. Bandpass filter your clapping data and the whistle data by typing the following into the Command Window:

yFiltered = bandpass(y, [2200 2800], 16000);
wFiltered = bandpass(W, [2200 2800], 16000);
figure
plotAudio(yFiltered)
title('filtered clapping')
figure
plotAudio(wFiltered)
title('filtered whistling')

Notice the dramatic difference in the filtered signals. The filtered clapping data still retains two high amplitude features whereas the filtered whistling data has no high amplitude features.