knobMoved()#
eventoav-p5function knobMoved(n, value) {}
You define this function; oav-p5 calls it whenever a knob moves.
Like mouseMoved() for knobs:
function knobMoved(n, value) {
// knob n is now at value
}It is called for every step the knob sends, so many times per second while it turns. To read a knob once a frame, use knob1 instead.
Parameters
| Name | Type | Description |
|---|---|---|
n | Number | Which knob (1 is the first, as printed on the controller). |
value | Number | Where it is now, 0..1. |
Examples
let last = 'turn a knob';
function setup() {
createCanvas(400, 300);
textAlign(CENTER, CENTER);
textSize(32);
}
function knobMoved(n, value) {
last = 'knob ' + n + ': ' + nf(value, 1, 2);
}
function draw() {
background(20);
fill(255);
text(last, width / 2, height / 2);
}Related
knob1The position of a controller knob, from 0 to 1:knob1is the first knob,knob2the second, up toknob8.faderMoved()You define this function; oav-p5 calls it whenever a fader 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.