open-audiovisual
Search GitHub

oav-p5 reference · Microphone and audio analysis

kickIsDetected#

variableoav-p5
kickIsDetected

Also: 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

jsOpenProcessing ↗
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);
}
The orange circle flashes on every kick and fades out, the blue one on every snare.

Related

  • kickDetected() You define these; oav-p5 calls them when the microphone (or the drum machine) hears a kick, a snare or a hat.
  • beat True for one frame each time the microphone (or the drum machine) hears a beat.
  • lastKickTs When the last kick (snare, hat, beat) came, on the millis() clock: millis() - lastKickTs is how many ms ago.
  • lag() Follows value smoothly instead of jumping: up in up seconds, down in down seconds (TouchDesigner's Lag CHOP).

p5/oav-p5.js, line 1072

↑ Back to top · All names