open-audiovisual
Search GitHub

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

noteIsDown()#

functionoav-p5
noteIsDown(n)

True while the key n (a MIDI number or a name like 'C4') is held down.

The MIDI version of keyIsDown(). noteIsDown('C4') is the same as noteIsDown(60): C4 is middle C. A name that is not a note ('H4', 'C-2') stops the sketch with a one-line card saying how to write it.

Parameters

NameTypeDescription
nNumber | StringThe key: a MIDI number (60) or a note name ('C4', 'c#4', 'Db3').

Returns

Boolean True if that key is down right now.

Examples

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

function draw() {
  background(20);
  fill(noteIsDown('C4') ? color(255, 211, 107) : 80);
  circle(width / 2, height / 2, 140);   // lights up while middle C is held
}
A circle that lights up only while C4 (middle C) is held. On the on-screen keyboard, middle C is the C labelled C4.

Related

  • noteIsPressed True while at least one key is held down.
  • noteNumber() Turns a note name like 'C4' into its MIDI number, 0 to 127.
  • notePressed() You define this function; oav-p5 calls it each time a key (or a pad) goes down.

p5/oav-p5.js, line 363

↑ Back to top · All names