open-audiovisual
Search GitHub

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

OAVp5.hardware#

variableoav-p5
OAVp5.hardware

Where Web MIDI stands: 'off', 'asking', 'connected', 'waiting', 'denied' or 'unavailable'.

'off': Web MIDI has not been asked for yet (see hardware). 'asking': waiting for the browser's permission answer. 'connected': allowed, and at least one device is plugged in (OAVp5.devices lists them). 'waiting': allowed, but no device yet: plug one in and it becomes 'connected' by itself. 'denied': the permission was refused. 'unavailable': the browser has no Web MIDI (Safari, iPad) or could not open it.

It is only about real hardware. The on-screen controller and a phone work in every state.

Type
String
Range
'off' | 'asking' | 'connected' | 'waiting' | 'denied' | 'unavailable'

Changes when the browser answers and whenever a MIDI device is plugged in or out.

Notes

  • In the 🩺 check-up, waiting is written as "no device found".

Examples

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

function draw() {
  background(OAVp5.hardware === 'connected' ? color(20, 60, 30) : 20);
  fill(255);
  text('Web MIDI: ' + OAVp5.hardware, 20, 30);
  text('devices: ' + (OAVp5.devices.join(', ') || 'none'), 20, 60);
}
Shows the state of Web MIDI and the devices found. The background turns green once a controller is connected. Plug one in to see it change.

Related

  • OAVp5.devices The names of the MIDI controllers plugged in, as the browser reports them: an array of text, empty when there is none.
  • OAVp5.connectHardware() Asks the browser for Web MIDI now, and returns a promise that says whether a real controller can be heard.
  • hardware When oav-p5 asks the browser for Web MIDI, which a real controller needs: auto at load, click when the 🎹 panel opens, or off.
  • 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 260

↑ Back to top · All names