knob()#
functionoav-p5knob(n)
Returns the position of knob number n, from 0 to 1: the same as knob1 to knob8, for any n.
Use it when the number of the knob is a variable: for (let i = 1; i <= 16; i++) bar(i, knob(i));. It also works in a sketch that has its own knob1, which oav-p5 then leaves alone.
Parameters
| Name | Type | Description |
|---|---|---|
n | Number | Which knob, counting from 1 (as printed on the controller). |
Returns
Number The knob's position, 0..1; 0 until it has been turned.
Examples
function setup() {
createCanvas(400, 300);
noStroke();
}
function draw() {
background(20);
fill(255);
for (let i = 1; i <= 8; i++) {
rect(i * 44 - 20, height - 20, 30, -10 - knob(i) * 250); // one bar per knob
}
}Related
knob1The position of a controller knob, from 0 to 1:knob1is the first knob,knob2the second, up toknob8.fader()Returns the position of fader numbern, from 0 to 1: the same asfader1tofader8, for anyn.pad()Returns how hard pad numbernis pressed, 0 to 1: the same aspad1topad16, for anyn.