lastNoteFrameCount#
變數oav-p5lastNoteFrameCount
看到上一個鍵按下的那一格的 frameCount:frameCount - lastNoteFrameCount 就是幾格以前。
lastNoteTs 的「數格子」版本:按下之後的第一格是 0,接下來 1、2、3……
- 型別
Number
畫面的編號,跟 frameCount 同一套數法,跟 note 一起更新。還沒按過任何鍵之前是 -Infinity。oav-p5 0.8.3 起。
範例
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
}相關
lastNoteTs上一個鍵是什麼時候按下的,用millis()的時鐘:millis() - lastNoteTs就是幾毫秒前。note最後被按下的那個鍵的 MIDI 號碼(0 到 127)。notePressed()你來定義這個函式。每當有一個鍵(或打擊墊)按下,oav-p5 就呼叫它。lastKickFrameCount看到上一下大鼓(小鼓、鈸、拍子)的那一格的frameCount:frameCount - lastKickFrameCount就是幾格以前。