open-audiovisual
Search GitHub

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

pad1#

variableoav-p5
pad1

Also: pad2 pad3 pad4 pad5 pad6 pad7 pad8 pad9 pad10 pad11 pad12 pad13 pad14 pad15 pad16

How hard a drum pad is pressed, from 0 to 1: pad1 is the first pad, up to pad16; 0 when it is let go.

Read it like a held mouse button that also knows how hard: if (pad1 > 0) fill(255, 90, 31). Pads are numbered in the order the controller's profile lists them. To react once per hit rather than ask every frame, define padPressed().

Type
Number
Range
0..1

The velocity of the hit while the pad is held (1 is as hard as the controller sends), and 0 as soon as it is released.

Before it has a value

Nothing to call. Web MIDI is asked for at load, exactly as for a knob (knob1); reading a pad also makes a missing or refused Web MIDI show as a card.

Examples

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

function draw() {
  background(20);
  fill(255, 90, 31);
  circle(width / 2, height / 2, 40 + pad1 * 260);   // swells while pad 1 is held
}
The circle swells while pad 1 is down, more for a harder hit. On the on-screen controller, click the first pad.

Related

  • pad() Returns how hard pad number n is pressed, 0 to 1: the same as pad1 to pad16, for any n.
  • padPressed() You define this function; oav-p5 calls it each time a drum pad is hit.
  • padReleased() You define this function; oav-p5 calls it each time a drum pad is let go.
  • knob1 The position of a controller knob, from 0 to 1: knob1 is the first knob, knob2 the second, up to knob8.

p5/oav-p5.js, line 1

↑ Back to top · All names