open-audiovisual
Search GitHub

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

OAVp5.wiring()#

functionoav-p5
OAVp5.wiring([dev])

Lists which controller knob, fader or pad drives which OpenProcessing OPC variable right now: [{ control: 'knob1', name: 'radius' }, …].

With OP Configurator, OPC.slider('radius', 10) declares a variable and oav-p5 wires the controller to the OPC variables in order: knob 1 to the first slider, knob 2 to the second, the faders after the knobs, pad 1 to the first toggle or button. This is the list of who drives what, the same one the panel prints under the controller and the console says once. Use it when a knob moves the wrong thing.

Parameters

NameTypeDescription
devStringWhose numbering to use: 'screen' (the controller shown in the panel) or a profile id such as 'akai-lpd8'. It matters for the faders, which are numbered after the knobs. optional default 'screen'

Returns

Array<Object> One { control, name } per wired variable: control is 'knob1', 'fader2', 'pad1' …, name is the OPC variable. A control the sketch reads itself also has sketch: true, and its slider no longer follows it. An empty array when there is no OPC on the page or opc is off.

Notes

  • midi.wiring(…) is the same function.

Examples

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

function draw() {
  background(20);
  fill(255);
  const wired = OAVp5.wiring();
  text(wired.length ? wired.map((w) => w.control + ' -> ' + w.name).join('\n') : 'nothing wired (no OPC here)', 20, 30);
}
Prints the controls and the OPC variables they drive, one per line. Outside OpenProcessing there is no OPC, so it says nothing is wired.

To be confirmed

Not tried with OpenProcessing's real OPC library: it was checked against a stand-in object with the same options shape ({ type: 'slider', name, min, max }). Outside OpenProcessing the result is an empty array.

Related

  • opc Whether oav-p5 wires the controller to the variables of OP Configurator (OpenProcessing's sliders and buttons): on or off.
  • knob1 The position of a controller knob, from 0 to 1: knob1 is the first knob, knob2 the second, up to knob8.
  • knob() Returns the position of knob number n, from 0 to 1: the same as knob1 to knob8, for any n.
  • pad1 How hard a drum pad is pressed, from 0 to 1: pad1 is the first pad, up to pad16; 0 when it is let go.
  • OAVp5.check() Runs the 🩺 check-up: the version, page, browser, microphone, MIDI, sound, drums, recording, wiring and hints, as a card to screenshot and as an object.

p5/oav-p5.js, line 278

↑ Back to top · All names