open-audiovisual
Search GitHub

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

velocity#

variableoav-p5
velocity

How hard the last key was pressed, from 0 to 1.

MIDI sends velocity as 0 to 127; oav-p5 hands you it divided by 127, so 1 is the hardest hit the controller can send.

Type
Number
Range
0..1

Set together with note when a key goes down; kept after release; 0 before any key.

Notes

  • A sketch with its own velocity keeps it; read midi.last.value.

Examples

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

function draw() {
  background(20);
  fill(255, 90, 31);
  circle(width / 2, height / 2, 20 + velocity * 300);   // a harder key makes a bigger circle
}
The circle stays at the size of the last key's velocity.

Related

  • note The MIDI number (0 to 127) of the last key pressed.
  • notePressed() You define this function; oav-p5 calls it each time a key (or a pad) goes down.
  • noteIsPressed True while at least one key is held down.

p5/oav-p5.js, line 326

↑ Back to top · All names