1

In my task, our android mobile app need to recognize the knock sound (when knock to the surface of mobile device) to open to the app.

I tried some ways but it only recognize about 80% of knock (some time I knock phone but it do not return it is knock sound) and sometime it recognize other sound as knock, like vowel 'a'.

Here are the 3 methods we used -

1. Recognize by hight pass filter:

2. Using sum of magnitude from 13kHz to 18kHz (refer this article) :

3. Using library (refer link)

All of this effort only recognize about 80% of knock sound and some time it recognize other sound as knock.

I am not sure about knock characteristics and how to recognize knock exactly (it recognize knock when I clap phone exactly). Any help is greatly appreciated!

Community
  • 1
  • 1
xuan
  • 51
  • 1
  • 4
  • Basically you need to check http://stackoverflow.com/questions/499795/given-an-audio-stream-find-when-a-door-slams-sound-pressure-level-calculation?lq=1 – Nikolay Shmyrev Dec 11 '14 at 21:13

1 Answers1

3
  1. Recognize by hight pass filter

No relation to knock

  1. Using sum of magnitude from 13kHz to 18kHz (refer this article) :

This is a reasonable direction but you need to add more features, in particular the energy in other frames nearby.

Using library

Not relevant

All your methods do not work because they have no relation to knock properties. To properly detect knock you need to figure out what distinguishes it from other sounds:

  1. Knock is very short in time
  2. Knock frequencies are in higher part of the spectrum.

So you need to implement the following algorithm:

  • Split audio on frames
  • Create FFT transform for every frame
  • Analyze FFT transform for every frame and neighbor frames and make sure the following:
    • Spectral energy for frame is concentrated in the upper part
    • Energy of frame is significantly higher than the energy of neighbor frames

Once you see both features you can signal about knock detected.

For the reference see knock spectrogram:

Knock spectrogram

A related algorithm with explanation is also covered here:

Given an audio stream, find when a door slams (sound pressure level calculation?)

If you want to further discriminate between sounds, for example recognizer clicks and doorslams from claps, then you might want to implement a classifier for the spectrum. You will need to collect more examples of claps and different sound and apply a machine learning toolkit on FFT values. An SVM should work reasonably well for this task.

Community
  • 1
  • 1
Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
  • Could you share us the characteristic of knock on phone's sound? your mean is KNOCK - PREV > THRESHOLD && NEXT - KNOCK < -THRESHOLD. To do this we need have the appropriate WINDOW type, WINDOW size and THRESHOLD, these parameters base on experiences but about sound we has vary less experience. – xuan Dec 12 '14 at 03:49
  • 1
    You can figure them yourself from few test samples – Nikolay Shmyrev Dec 12 '14 at 10:00