open-audiovisual
Search GitHub

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

pad()#

functionoav-p5
pad(n)

Returns how hard pad number n is pressed, 0 to 1: the same as pad1 to pad16, for any n.

The function form of pad1.

Parameters

NameTypeDescription
nNumberWhich pad, counting from 1.

Returns

Number The velocity while the pad is held (0..1), 0 when it is released.

Examples

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

function draw() {
  background(20);
  for (let i = 1; i <= 8; i++) {
    fill(255, 90, 31, 60 + pad(i) * 195);
    square(20 + ((i - 1) % 4) * 92, 40 + floor((i - 1) / 4) * 110, 80);
  }
}
A grid of eight squares that light up under the pads you hit.

Related

  • pad1 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.
  • knob() Returns the position of knob number n, from 0 to 1: the same as knob1 to knob8, for any n.
  • padPressed() You define this function; oav-p5 calls it each time a drum pad is hit.

p5/oav-p5.js, line 362

↑ Back to top · All names