lastNoteTs#
variableoav-p5lastNoteTs
When the last key went down, on the millis() clock: millis() - lastNoteTs is how many ms ago.
Any key counts: a MIDI keyboard, the 🎹 on screen, a phone. Releasing a key does not change it.
- Type
Number
Milliseconds on the same clock as millis(), set with note and velocity; -Infinity before any key. Since oav-p5 0.8.2.
Examples
function setup() {
createCanvas(400, 300);
noStroke();
}
function draw() {
background(20);
const ago = millis() - lastNoteTs; // ms since a key went down
fill(255, 200 * exp(-ago / 400) + 30);
circle(200, 150, 60 + 160 * exp(-ago / 400));
}Related
noteThe MIDI number (0 to 127) of the last key pressed.velocityHow hard the last key was pressed, from 0 to 1.notePressed()You define this function; oav-p5 calls it each time a key (or a pad) goes down.lastKickTsWhen the last kick (snare, hat, beat) came, on themillis()clock:millis() - lastKickTsis how many ms ago.