1
\$\begingroup\$

I brought a clap activated switch project to practise my soldering. I realised clap activated was really sound activated. Is there a way I can get it to be able to tell the difference between me talking to myself and clapping?

I was assuming I can some how get it to only work within certain frequency.

\$\endgroup\$
2
  • \$\begingroup\$ Have a look at this wiki article on filters. Sorry I can't make this good enough to be an answer but its a good starting point. \$\endgroup\$ – Dean Sep 4 '11 at 16:18
  • 2
    \$\begingroup\$ I appreciate you accepting my answer, but you should consider next time waiting for a reasonable number of answers first, or at least a reasonable time for people to provide answers. \$\endgroup\$ – Olin Lathrop Sep 4 '11 at 18:40
2
\$\begingroup\$

Take a look at a clap signal and a normal talking signal on the scope. Probably the biggest difference will be the sudden spike from the clap. There is probably a frequency content difference too, but I suspect it will be easier to detect a clap in the time domain.

One way to test this is to record a few samples of the signals you want to detect and reject, then work up a algorithm on the host that scans the WAV files and makes a decision. Once you have that figured out, you can code it in a small DSP, like a Microchip dsPIC.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks olin. I didn't anticipate it would be this challenging. I think the root of the problem is the human voice covers a wide spectrum hence it's difficult to isolate. I.e. clapping easily 1000 to 20000 hz which within voice spectrum. \$\endgroup\$ – Ageis Sep 4 '11 at 17:24
  • \$\begingroup\$ Yes, this looks messy in the frequency domain. However, I don't think this is all that difficult in the time domain. \$\endgroup\$ – Olin Lathrop Sep 4 '11 at 18:41
3
\$\begingroup\$

What's typical for clapping hands is that it's a sudden short, but strong sound.
A possible way to detect it is to trigger an MMV (Monostable MultiVibrator) with the input signal if it's higher than a certain threshold, and see if this high level is still present when the MMV times out. If it isn't it was probably clapping hands. You'll have to experiment with threshold level and MMV time.

\$\endgroup\$
3
\$\begingroup\$

Voice is what we call "band limited". Meaning that it has a fairly well defined frequency band. A clap is essentially an "impulse" which is "broad-band" and thus has a very wide frequency range.

To put it another way, if you looked at the spectrum analysis of voice then you'd see stuff in the 200 Hz to about 12 KHz range. If you did the same for a hand clap then you'd see stuff from 100 Hz to beyond 20 KHz.

A hand clap also happens quickly, where voice goes on and on (and on and on and on :).

To build something that can distinguish between a clap and a loud voice then you would start by taking the audio and breaking it up into three or more frequency bands. Let's say <200 Hz, 400Hz to 8 KHz, and >13 KHz. You would then make a detector for each band which would detect peaks greater than some threshold, but not for more than about 200 ms. If you get a short peak on all three bands then you have detected a clap. If you don't get all three bands, or it is greater than 200 ms, then you have just loud voice.

Note: I'm doing an educated guess on the frequencies that I've mentioned here. They are approximately correct, but not 100% accurate. IF you want to do this approach I can kludge together a realistic test using real sound equipment-- to get the exact frequencies and time limits. It would take me about an hour to do, so I don't want to do it if you're not serious. But if you are serious, this could save you a lot of time (a lot more than an hour).

\$\endgroup\$
1
\$\begingroup\$

As the others have mentioned, a simple short width peak amplitude detector (is level above x? -> wait ~100ms -> is level below x?) would be probably the simplest way. I just ran a small test (using Visual Analyser) with the time domain and frequency domain capture (x axis is logarithmic to 30kHz) and as you can see the time domain would be easier to work with, though you could run more tests and fine tune things based on comparison with speech (and other common sounds):

ClapCapture

Edit - Here is another capture of speech (a spoken "hello") in order to compare things. Note the different frequency content (I zoomed in the x axis as no significant content above 10kHz or so)

Voice Capture

\$\endgroup\$
0
\$\begingroup\$

The answer is a Zero-Crossing counter. This is non-cpu-intensive, easily computed in the time domain, but gives you a crude (but good enuf) estimate of the dominant frequency. I posted this answer in another forum, it is here:

http://arduino.cc/forum/index.php/topic,70740.msg527874.html#msg527874

My pictures are not as nice as the spectrograms in the previous answer, but make the same point. If u just count zero crossings, you will find MANY more in a clap than in a voice. But I repeat myself, see the above post...

\$\endgroup\$

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.