velocity#
variableoav-p5velocity
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
velocitykeeps it; readmidi.last.value.
Examples
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
}Related
noteThe 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.noteIsPressedTrue while at least one key is held down.