detect impact from digital audio I've started a hobby project which is to detect and count the number of impacts (for example someone clapping, bouncing a ball or hitting a boxing bag).

I've been reading and playing around (in java) with a few variations of total amplitude, FFT, IIR etc but with so much information and concepts to grasp (I'm normally a web/database developer) I can't figure out which is the right path to follow.

practically speaking I know i'll need a high frequency sample rate in order to distinguish between peaks and i think i'll need some form of filtered amplitude to distinguish between the crisp leading edge of the impact and the rumble noise that may follow.

I'm hoping someone here can point me in the right direction.

Thanks for your time!
If your environment's noise level allows it, you can use a quiet no-brainer solution. Just make sure that the impacts have greater peak amplitude than the noise floor in every case.


Specify a threshold level based on previous experiments. This level has to be great enough for all the impacts you generate and you want to detect. If your signal crosses the level, you can assume, that an impact has happened.
If a detection has occurred, you can start a timer, that prevents unwanted re-detection for the same impact because you can't expect that your impact will be below the threshold for the next sound sample. For this reason, the timer has to run longer than the maximum detectable length of any impacts. Until the timer runs, you disable the threshold detection.
After the timer has fired, you can enable the threshold detection again.




This method requires previous experiment and knowledge about the detectable impacts. You have to determine the minimum sampling rate that allows you to catch at least a few sample of the impact. Standard audio quality sampling rate would be good enough.

You can of course apply signal conditioning by filtering the signal with a digital filter, but this necessity is highly depends on your environment and noise floor.

Note that this is possibly the most no-brainer solution. There are many more sophisticated methods for this particular problem.