kickIsDetected#
variableoav-p5kickIsDetectedAlso: snareIsDetected hatIsDetected
True in the one frame after a kick (snare, hat) is heard, from the drum machine or the microphone, like mouseIsPressed for a hit.
The same hits that call kickDetected(), snareDetected() and hatDetected(), as a value you read in draw() instead of a function you write. Hand it to lag() and it becomes a number that jumps to 1 on the hit and fades: lag(kickIsDetected, 0, 0.3) is 1 on a kick and back near 0 about 0.3 s later, ready for an alpha or a size. lag() takes true as 1.
While the drum machine plays, only its hits count. Reading these does not ask for the microphone by itself: with no drums, it counts as wanting the microphone's hits, the way defining kickDetected() does, so the first click on the page opens it.
- Type
Boolean
True for exactly one p5 frame per hit, however often that frame reads it; false otherwise. Since oav-p5 0.8.2.
Examples
function setup() {
createCanvas(400, 300);
startDrums('bd*4, ~ sd ~ sd', 110);
noStroke();
}
function draw() {
background(20);
fill(255, 90, 31, 255 * lag(kickIsDetected, 0, 0.3)); // a kick lights it, then it fades
circle(130, 200, 140);
fill(120, 190, 255, 255 * lag(snareIsDetected, 0, 0.3));
circle(270, 200, 140);
}Related
kickDetected()You define these; oav-p5 calls them when the microphone (or the drum machine) hears a kick, a snare or a hat.beatTrue for one frame each time the microphone (or the drum machine) hears a beat.lastKickTsWhen the last kick (snare, hat, beat) came, on themillis()clock:millis() - lastKickTsis how many ms ago.lag()Followsvaluesmoothly instead of jumping: up inupseconds, down indownseconds (TouchDesigner's Lag CHOP).