knob1#
variableoav-p5knob1Also: knob2 knob3 knob4 knob5 knob6 knob7 knob8
The position of a controller knob, from 0 to 1: knob1 is the first knob, knob2 the second, up to knob8.
Read it in draw() the way you read mouseX: background(knob1 * 255). Knobs are numbered the way they are printed on the controller, so knob 1 is knob 1 on any controller OAV has a profile for: the MiniLab 3's first knob is CC 74, the LPD8's is CC 70. The sketch never needs to know a CC number.
On a controller OAV has no profile for, the first knob you turn becomes knob1, the next one knob2, and so on, in the order you turn them. Past eight, use knob(n).
- Type
Number- Range
0..1
Changes when the knob moves, not once per frame; the sketch just reads the latest value. 0 until the knob has been turned.
Before it has a value
Nothing to call. With the default hardware=auto, oav-p5 asks the browser for Web MIDI as soon as it loads, whatever the sketch reads (Chrome, Edge and Firefox have it; Safari and iPad do not: use 🎹 or a phone there). Reading a knob also tells oav-p5 the sketch plays from MIDI, so when Web MIDI is missing or refused a card beside the 🎹 says so; a sketch that uses none of this never sees that card. ?oav_hardware=click waits for the 🎹 panel instead.
Notes
- A sketch that already has its own
knob1(alet, a function) keeps it, and a card beside the 🎹 says what to read instead (knob(1)). - With OP Configurator, knobs also drive the OPC sliders in the order they are declared. A knob the sketch reads itself stays the sketch's: that slider no longer follows it.
Examples
function setup() {
createCanvas(400, 300);
}
function draw() {
background(knob1 * 255); // knob 1 sets the brightness
}function setup() {
createCanvas(400, 300);
colorMode(HSB, 1);
}
function draw() {
background(0.65, 0.5, 0.15);
fill(knob2, 0.8, 1); // knob 2: colour
circle(width / 2, height / 2, 40 + knob1 * 300); // knob 1: size
}Related
knob()Returns the position of knob numbern, from 0 to 1: the same asknob1toknob8, for anyn.fader1The position of a controller fader (slider), from 0 to 1:fader1is the first fader, up tofader8.pad1How hard a drum pad is pressed, from 0 to 1:pad1is the first pad, up topad16; 0 when it is let go.knobMoved()You define this function; oav-p5 calls it whenever a knob moves.noteIsDown()True while the keyn(a MIDI number or a name like'C4') is held down.