open-audiovisual
Search GitHub

oav-p5 reference · MIDI: knobs, faders, pads, keys

lastNoteFrameCount#

variableoav-p5
lastNoteFrameCount

The frameCount of the frame that saw the last key go down: frameCount - lastNoteFrameCount is how many frames ago.

The frame-counting twin of lastNoteTs: 0 in the first frame after the key, then 1, 2, 3 …

Type
Number

A frame number, on the same count as frameCount, set with note; -Infinity before any key. Since oav-p5 0.8.3.

Examples

jsOpenProcessing ↗
function setup() {
  createCanvas(400, 300);
  noStroke();
}

function draw() {
  background(20);
  const f = frameCount - lastNoteFrameCount;    // frames since a key went down
  fill(120, 190, 255);
  circle(200, 150, max(0, 200 - f * 5));        // shrinks by 5 px a frame
}
Each key you press (on 🎹 too) brings back a big circle that shrinks 5 px a frame.

Related

  • lastNoteTs When the last key went down, on the millis() clock: millis() - lastNoteTs is how many ms ago.
  • note The MIDI number (0 to 127) of the last key pressed.
  • notePressed() You define this function; oav-p5 calls it each time a key (or a pad) goes down.
  • lastKickFrameCount The frameCount of the frame that saw the last kick (snare, hat, beat): frameCount - lastKickFrameCount is how many frames ago.

p5/oav-p5.js, line 333

↑ Back to top · All names