open-audiovisual
Search GitHub

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

OAVp5.bend#

variableoav-p5
OAVp5.bend

Where the pitch wheel is, from −1 (all the way down) through 0 (middle) to 1 (all the way up).

Read it in draw() like a knob that goes both ways: x = width / 2 + OAVp5.bend * 150. MIDI sends the position as 14 bits (0 to 16383, with 8192 in the middle). oav-p5 maps the two halves to −1..0 and 0..1, so full travel reaches exactly −1 and 1. To be told on every movement, define pitchBend().

Type
Number
Range
-1..1

Changes when the wheel moves. 0 before it has moved, and again when a spring-loaded wheel returns to the middle.

Notes

  • midi.bend is the same number. There is no plain bend variable.

Examples

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

function mouseDragged() {
  OAVp5.input([0xE0, 0, constrain(round(mouseX / width * 127), 0, 127)]);   // no wheel? drag the mouse
}

function draw() {
  background(20);
  circle(width / 2 + OAVp5.bend * 150, height / 2, 50);   // wheel up: right, wheel down: left
  text('bend ' + nf(OAVp5.bend, 1, 2), 20, 30);
}
The circle follows the pitch wheel. No wheel? Drag the mouse across the canvas: it sends the same message.

Related

  • pitchBend() You define this function; oav-p5 calls it whenever the pitch wheel moves, with its position from −1 to 1.
  • OAVp5.cc An array of 128 numbers, one per MIDI controller number: where each control last was, 0 to 1. OAVp5.cc[1] is the mod wheel, OAVp5.cc[64] the sustain pedal.
  • OAVp5.note An array of 128 numbers, one per MIDI key: how hard that key is held, 0 to 1, and 0 when it is up. OAVp5.note[60] is middle C.

p5/oav-p5.js, line 574

↑ Back to top · All names