[Minim] Clap Recognition

edited March 2015 in Library Questions

Hi guys,

I am trying to implement a simple clap recognition with Minim. The idea is to take the AudioInput, run through all values in the buffer and find the maximum value max. Then I compare max and lastMax.

setup() {
    minim = new Minim(this);
    frameRate(60); // draw framerate

    in = minim.getLineIn(Minim.STEREO, 1024, 44100);

draw() {

  // find maximum value in buffer
  for (int i = 0; i < in.bufferSize () - 1; i++) {
      if (abs(in.mix.get(i)) > max) max = abs(in.mix.get(i));

 // initialize sensitivity

 if (sensitivity > 0 && (max / lastMax) > sensitivity) {
    // clap

 lastMax = max;

It already works, but simply skips some claps even though they are very loud. I guess this is a problem with the buffersize "1024". Do you have any idea what value I should choose for framerate "60"? ...or is there a better way to recognize a clap?

Thanks a lot!


Sign In or Register to comment.