0

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

  • Hi Ryan, welcome. I can see why you asked this question on here, but I think you would get a better response if the question was asked on the Electronics Exchange forum because its something someone may have done on a none Arduino platform that you could port. If you agree then flag the question for moderator attention and ask them to move it. (Don't cross-post, its like poking a wasps nest!) – Code Gorilla Sep 15 '16 at 8:06
  • You could try the following: get a sound frequency specific to the applause, convert it with an analog signal and filter it with an Inductor/RC type circuit whose output goes into Arduino for further processing. – qwerty10 Sep 17 '16 at 17:48
5

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:

  1. Use the program as is, to record and plot the sound intensity as a function of time.
  2. Test various types of sounds: applause, laughter, speech, noise...
  3. 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.
  4. 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.
  5. Test your code on your computer, on the data previously recorded.
  6. Debug, fine-tune... until you are happy with your detection algorithm.
  7. 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!

  • This looks pretty great. I think I can work with this. I'm going to plug it in and see what kinds of values I get. From there I may have an output signal trigger an Arduino Nano running the code for the Neopixels. Touching interrupts in a program running Neopixels can be a bit problematic. Neopixels require very specific timing and sometimes interrupts can disrupt that signal, as I've found out the hard way. This isn't a bad thing though. One development of our project is that we may be putting it onto multiple boards. We could have a Nano for each independent board. This would work splendidly – Ryan Sep 15 '16 at 20:00
  • I'm attempting to recreate the "Sound Sensor Example" project (arduino.org/learning/tutorials/boards-tutorials/…), which does use analogRead to detect sound, and operates with a 100 millisecond delay (i.e. 10 Hz sampling). Is this approach totally flawed, or just not suited to detailed analysis of sound waves? – yoyo Dec 30 '16 at 22:57
  • @yoyo: At this rate, you can only reliably sample signals slower than 5 Hz, and you will only get one or two samples out of a clap. Those samples will essentially be random numbers between offset − amplitude and offset + amplitude. Only when they are in the high part of the range will they be identified as a clap. You can probably expect to detect most of the claps, but do not expect the detection to be reliable. – Edgar Bonet Dec 31 '16 at 11:24
  • @EdgarBonet thanks for the info. I used the analogRead technique to pretty reliably detect and count claps, but I look forward to using interrupts for more detailed sound analysis. – yoyo Jan 3 '17 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.