user26639: I'm making a pretty basic light circuit and I'd like to have it react to applause or laughter, but NOT during regular speech, amplified over speakers.
I'm wondering if anyone has already made a function for this that I could use in this design!
Your help is greatly appreciated! Thanks for being awesome people who help educate, assist, and elevate others in their creative journeys. You're the best!
Ryan

user7508: 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
furiously
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
Arduino Uno.
If you want to make an applause detector form this, I suggest the
following approach:

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
some creativity.
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
algorithm.
Modify my sound-meter program: remove the last statement
(transmitting the data to the host computer) and replace it with your
detection code.

Good luck!

26639: <p>I'm making a pretty basic light circuit and I'd like to have it react to applause or laughter, but NOT during regular speech, amplified over speakers.</p>

<p>I'm wondering if anyone has already made a function for this that I could use in this design!</p>

<p>Your help is greatly appreciated! Thanks for being awesome people who help educate, assist, and elevate others in their creative journeys. You're the best!</p>

<p>Ryan</p>
 7508: <p>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: <a href="https://gist.github.com/edgar-bonet/e693799f58a545ca89a2" rel="noreferrer">Arduino sound meter</a>. It works as follows:</p>

<ul>
<li>the analog input is read at a constant rate of about 9600 samples per
second, which is normally fine for telephone quality audio processing</li>
<li>the DC offset from the microphone is removed</li>
<li>the readings are squared in order to get the instantaneous sound
intensity; note that this is not immediately usable, as it fluctuates
furiously</li>
<li>this is run through a first order low-pass filter with a time constant
of 26.6&nbsp;ms in order to get a usable sound intensity reading</li>
<li>the readings are decimated to keep only one every 26.6&nbsp;ms</li>
<li>they are sent to the PC through the serial port.</li>
</ul>

<p>The program does not use the <code>analogRead()</code> 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
Arduino Uno.</p>

<p>If you want to make an applause detector form this, I suggest the
following approach:</p>

<ol>
<li>Use the program as is, to record and plot the sound intensity as a
function of time.</li>
<li>Test various types of sounds: applause, laughter, speech, noise...</li>
<li>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
some creativity.</li>
<li>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.</li>
<li>Test your code on your computer, on the data previously recorded.</li>
<li>Debug, fine-tune... until you are happy with your detection
algorithm.</li>
<li>Modify my sound-meter program: remove the last statement
(transmitting the data to the host computer) and replace it with your
detection code.</li>
</ol>

<p>Good luck!</p>
