open-audiovisual
Search GitHub

oav-p5 reference · Microphone and audio analysis

lastKickFrameCount#

variableoav-p5
lastKickFrameCount

Also: lastSnareFrameCount lastHatFrameCount lastBeatFrameCount

The frameCount of the frame that saw the last kick (snare, hat, beat): frameCount - lastKickFrameCount is how many frames ago.

The frame-counting twin of lastKickTs. frameCount - lastKickFrameCount is 0 in the frame where kickIsDetected is true, then 1, 2, 3 …, so a shape can last a fixed number of frames after each hit. Use the Ts version when it should last a fixed time whatever the frame rate.

Type
Number

A frame number, on the same count as frameCount; -Infinity before the first hit. Since oav-p5 0.8.3.

Examples

jsOpenProcessing ↗
function setup() {
  createCanvas(400, 300);
  startDrums('bd*4, ~ sd ~ sd', 110);
  noStroke();
}

function draw() {
  background(20);
  const k = frameCount - lastKickFrameCount;    // frames since the kick
  if (k < 10) {                                 // the ring stays for 10 frames after each kick
    fill(255, 90, 31);
    circle(200, 200, 60 + k * 16);
  }
}
After every kick a circle shows for ten frames, growing each frame.

Related

  • lastKickTs When the last kick (snare, hat, beat) came, on the millis() clock: millis() - lastKickTs is how many ms ago.
  • kickIsDetected True in the one frame after a kick (snare, hat) is heard, from the drum machine or the microphone, like mouseIsPressed for a hit.
  • lastNoteFrameCount The frameCount of the frame that saw the last key go down: frameCount - lastNoteFrameCount is how many frames ago.

p5/oav-p5.js, line 333

↑ Back to top · All names