open-audiovisual
Search GitHub

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

faderMoved()#

eventoav-p5
function faderMoved(n, value) {}

You define this function; oav-p5 calls it whenever a fader moves.

The fader twin of knobMoved(): function faderMoved(n, value) { … }.

Parameters

NameTypeDescription
nNumberWhich fader (1 is the first).
valueNumberWhere it is now, 0..1.

Examples

jsOpenProcessing ↗
let level = 0;

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

function faderMoved(n, value) {
  if (n === 1) level = value;   // fader 1 only
}

function draw() {
  background(20);
  fill(255);
  rect(40, height - 40, level * (width - 80), 24);
}
A bar that follows fader 1, driven by the event instead of a read.

Related

  • fader1 The position of a controller fader (slider), from 0 to 1: fader1 is the first fader, up to fader8.
  • knobMoved() You define this function; oav-p5 calls it whenever a knob moves.
  • 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.

p5/oav-p5.js, line 254

↑ Back to top · All names