Detect "clap" in potentially windy, noisy environment

New to audio detection/processing with arduino, so I'd love some direction on how to [title].

I've seen some tutorials on google that are unfortunately sparse with information beyond "buy this mic, plug x into y, copy paste this code, like and subscribe".

Amazon has some "Electret Condenser Microphone Pickup"s, but I notice only 2 pins and no chip/circuitry as I see in the tutorial videos.

Do the sensors in the videos have built-in "clap detection" circuitry (and then just expose some toggle state via a digital pin)? Is an arduino performant enough to reliably parse realtime "analog" audio" (at least enough to differentiate a clap) without such a chip?

My worry is that any built-in circuitry won't be dynamic enough to differentiate a clap vs a gust of wind on a blustery day (if it's not calibrated for my environment, I'm SOL). Is this fear legitimate?

How would you approach this problem?

Note- I don't need to differentiate the acoustic profile of a "clap" from a "stomp" from a "hit" or anything like that. Hoping "1ms audio spike" is sufficiently discriminatory. (The "noise" will be limited to people talking and bustling about outdoors- if a particularly abrupt shriek triggers it, that's not a problem either.)

Also, I always have "use a nice computer microphone and analyze the data in realtime with python" or something as a fallback. Just am curious if this is feasible using arduino.

Thanks!

It is impossible for us to say what you will need to do to recognize a specific sound in a noisy environment.

Yes, it is "feasible", but it is not at all a simple problem. The problem depends on the equipment, the sound, the noise, the approach and most importantly, your specification for detection accuracy.

If you manage to solve it, you will have learned a great deal, so keep us posted.

Most Arduino sound detectors just operate on the sound volume. Basically they pick up loud noises, any loud noises. There is no more differentiation than that.

Picking up a specific sound in a noisy environment is a difficult problem even with good microphones and a serious computer. Not really an Arduino job at all.

Steve

I'm very surprised by this- to be clear: All I want is to detect "quick" loud noises (ie, a "clap"), with the ability to differentiate that from a "sustained" loud noise (ie, a "scream"). There is no "audio analysis" required beyond that.

Like, clapper lights are a thing for $5- do those not work even if you have light music on? By "noisy environment", I just mean "I can't assume total silence"- people will likely be talking in the background (again, similar to the noise environment of a clapper light).

If I get "volume" as an analog reading 100 or so times per sec, I would assume my only issue would be to make sure the sensor isn't too sensitive (it should otherwise be easy to keep track of and test for "is volume above some threshhold for < 10ms" [or however long a clap noise lasts]).

Can I get volume as an analog reading 100 or so times per sec? What kind of sensor should I look into to do this? Is there such a sensor that has a sensitivity range such that the volume of a clap registers as a spike relative to talking? Does the possibility of wind render this whole experiment impossible?

Is there something I'm not understanding here?

I'd say, get a mic, hook it up to a scope and do some experiments.

You seem to state and assume many things with conclusions that are questionable to say the least.

I've posted at least 5 direct questions and have gotten "this is a pretty hard problem", "this is an impossible problem", and "figure it out". I'm fine with big picture discussion, but when responses are in conflict with not only my expectations, but also each other, I don't know a better way to get to the root of the problem than to be explicit about my assumptions and ask them to be checked.

The root of the problem is that you have not done any experiments, and have no valid information about how difficult the problem might be, under the circumstances you have set forth.

Get an Arduino, a couple of different microphone modules, do some experiments and prove to yourself that you can reliably detect a clap in a windy, noisy environment.

People would welcome a post showing the solution to the problem.

I think you are looking for something simple like this Sound Detection Sensor Module Electret Condenser Microphone Arduino PIC Pi LM393 | eBay. You can set the "loudness" threshold using the trimmer, and you can measure the duration of the signal when a loud sound is detected to differentiate from your "sustained" noise. I think this is one of the simplest way to do it because you "don't need to differentiate the acoustic profile of a "clap" from a "stomp" from a "hit" or anything like that". To accurately do this, there really is no simple solution.

Byork:
To accurately do this, there really is no simple solution.

He has stated he doesn't want to hear that! :astonished:

Provided the noise you're interested in is going to be considerably louder than the background noise at the time then a simple sound detector will do it. You just need to experiment to get the threshold right and yes you can easily measure how long the noise exceeds the threshold for so short vs long noises are fine.

If the interesting noise is likely to be masked by the level of the background then you're out of luck.

So do some experimenting in the conditions you're interested in. You started off talking about "windy, noisy environment" then moved on to "can't assume total silence". That's not exactly a very definite specification.

Steve

Get an oscilloscope and look at the patterns of the background noise.

Write a software filter that is Dynamic in such that it reports a relative magnitude of the background energy.

Subtract that value in real time from the detected value. Note ' real time' is a mathematical term.

Any value outside of that pattern is your added value.

Study Dolby.

I think you will need an SBC like a Pi as this will be a heavy burden on the processor .
I assume that the reason we didn't have answers is because your need is not in the rhealm of the Arduino due to the processing requirements

Also read how noise canceling is done.

Basically an inverse value of equal magnitude dynamically generated in the undesirable frequency ranges

Paul__B:
He has stated he doesn't want to hear that! :astonished:

What are you talking about. Why do you do this with your life.

Thanks to those who earnestly engaged with the problem. I've ordered an array of mic+chip modules (these appear similar to the recommendation by byork- thanks!) which apparently just give binary "loud" or "not" readings, and plan to calibrate each to a different threshhold of "loudness" (w/ each's built-in potentiometer). From that, I'll have a dynamic "levels" meter, and, assuming the performance is such that I can iterate through them a hundred times a second or so, I should be able to easily detect a sharp rise in volume and a quick falloff (in code), and consider that a "clap". If I need to, I'll cover the whole thing in foam if wind is an outlier problem.

This seems like as good of a start as I'm going to get. I'm still deeply skeptical that I need to concern myself with noise cancelling, or anything that requires significant computation. If I end up needing a pi, I'll be surprised, but that at least seems within reason. [worst case- I throw a clapper light in a black box with a photosensor attached to an arduino.]

phildo:
What are you talking about. Why do you do this with your life.

One might just as well ask you the same question! :astonished:


I was about to comment that your suggestion of using multiple sensors set to alternate levels was overly complex and simply reading the analog level with the Arduino ADC would be more appropriate - and that could well be the case.

So I looked into the four-terminal "sensors" that are available such as Byork cited, or at least looked for the circuit (which as it turns out, is on that listing) and was mightily disappointed.

Pretty useless. :roll_eyes:

If I find one of these "sensors" rummaging through my wonder bins, I will see what it does - or does not do. :grinning:

The device that you've ordered has a digital (low or high) output when the sound power is above a threshold set by the potentiometer (the blue boxy thing with the slotted adjustment on top). With this you can, by trial and error, adjust the threshold to ignore background noise below some threshold and it will detect (at the digital output) your clap (or anything else) that exceeds the threshold. You might be able to improve on that in software by discriminating between short duration "clap-like" pulses and longer duration events, limit recurrence rates, and such.

With a microphone module with a analog output and using the Arduino "AnalogRead()" it wouldn't be too difficult to program automatic thresholding that dynamically adjusts the threshold for detection to be some level above the background noise. This should perform better in general, but will eventually fail when background noise gets loud enough, though it would tend to fail as "no detection" rather than "false detection" which might be more desirable in a particular application.

If it were my project, I'd consider prototyping the algorithm with a laptop PC and microphone in Python, Matlab, or some such interactive environment that allows for visualization of the signal of interest and background noise.

MrMark:
With a microphone module with a analog output and using the Arduino "AnalogRead()" it wouldn't be too difficult to program automatic thresholding that dynamically adjusts the threshold for detection to be some level above the background noise.

Point is, the modules available - or at least those cited - do not amplify the microphone signal to make it usable. :roll_eyes:

The MEMS microphone module might ...

Paul__B:
If I find one of these "sensors" rummaging through my wonder bins, I will see what it does - or does not do. :grinning:

The i wonder why I bought that bin?

Paul__B:
Point is, the modules available - or at least those cited - do not amplify the microphone signal to make it usable. :roll_eyes:

The MEMS microphone module might ...

I've had good success with the AD9814 based electret microphones (selectable 40-60 dB gain) at the highest gain configuration providing reasonable levels for the Arduino ADC, but in the context of normal indoor sound levels.

MrMark:
I've had good success with the AD9814 based electret microphones (selectable 40-60 dB gain) at the highest gain configuration providing reasonable levels for the Arduino ADC, but in the context of normal indoor sound levels.

Hmmm.

Cheap knock-off.

Sounds promising. Datasheet.

Note that it may be possible on this chip, to connect the AGC capacitor to an analog input and use it to determine the loudness of the sound!