OAVp5.hardware#
variableoav-p5OAVp5.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,
waitingis written as "no device found".
Examples
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);
}Related
OAVp5.devicesThe 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.hardwareWhen oav-p5 asks the browser for Web MIDI, which a real controller needs:autoat load,clickwhen the 🎹 panel opens, oroff.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.