Not really an applause detector, but I have written a sound meter
program you could use as a starting point for your own project. It is
available here: Arduino sound meter. It works as follows:
- the analog input is read at a constant rate of about 9600 samples per
second, which is normally fine for telephone quality audio processing
- the DC offset from the microphone is removed
- the readings are squared in order to get the instantaneous sound
intensity; note that this is not immediately usable, as it fluctuates
- this is run through a first order low-pass filter with a time constant
of 26.6 ms in order to get a usable sound intensity reading
- the readings are decimated to keep only one every 26.6 ms
- they are sent to the PC through the serial port.
The program does not use the
analogRead() function, because it is
really not suited for this kind of real-time sampling. Instead, it
directly accesses the ADC, it configures it in the so called “free
running mode” and uses the ADC interrupt to retrieve the samples. This
limits the portability of the program, which has been written for an
If you want to make an applause detector form this, I suggest the
- Use the program as is, to record and plot the sound intensity as a
function of time.
- Test various types of sounds: applause, laughter, speech, noise...
- Look carefully at the plots and try to see how the sounds you want to
detect are different from those you do not want: high peaks? short
peaks? fast rise times? You will have to make up some criteria to
tell them apart. This is the most difficult part, as it will require
- Write some code to apply your criteria. Keep in mind that your code
will ultimately have to run in real time, i.e. process one intensity
sample at a time. It will not have the whole record to start with.
- Test your code on your computer, on the data previously recorded.
- Debug, fine-tune... until you are happy with your detection
- Modify my sound-meter program: remove the last statement
(transmitting the data to the host computer) and replace it with your