open-audiovisual
Search GitHub

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

OAVp5.cc#

variableoav-p5
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.

The array version of controlChange(): read any controller in draw() without defining a function. It holds every CC, including the ones that are not a knob or a fader, such as the mod wheel (1), the volume (7) and the sustain pedal (64, which counts as down at 0.5 and above). The MIDI channel is ignored: the latest value of that controller number wins, whichever channel it came on.

Type
Array<Number>
Range
128 numbers, 0..1 each

The index is the controller (CC) number, 0 to 127; the value is the last one received divided by 127. Changes when a message arrives. 0 before a control has moved, which is not the same as "at 0".

Notes

  • midi.cc is the same array. The friendly names knob1 and fader1 are looked up through the controller's profile and read the same data.

Examples

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

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

function draw() {
  background(OAVp5.cc[64] >= 0.5 ? 90 : 20);   // sustain pedal down: lighter
  circle(width / 2, height / 2, 40 + OAVp5.cc[1] * 300);   // mod wheel: size
}
The mod wheel (CC 1) sets the size of the circle and the sustain pedal (CC 64) lightens the background. No controller? Drag the mouse across the canvas: it sends CC 1.

Related

  • controlChange() You define this function; oav-p5 calls it for every MIDI control change (a knob, a fader, the mod wheel, the sustain pedal), whether or not the controller is known.
  • knob1 The position of a controller knob, from 0 to 1: knob1 is the first knob, knob2 the second, up to knob8.
  • fader1 The position of a controller fader (slider), from 0 to 1: fader1 is the first fader, up to fader8.
  • 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.
  • OAVp5.bend Where the pitch wheel is, from −1 (all the way down) through 0 (middle) to 1 (all the way up).

p5/oav-p5.js, line 258

↑ Back to top · All names