open-audiovisual
Search GitHub

oav-p5 reference · Loading options

hardware#

optionoav-p5
?oav_hardware=auto | click | off

When oav-p5 asks the browser for Web MIDI, which a real controller needs: auto at load, click when the 🎹 panel opens, or off.

With auto, oav-p5 asks for Web MIDI as soon as it loads, so a plugged-in controller plays the sketch without anyone pressing anything. The browser remembers your answer per site. With click, it asks only when the 🎹 panel is first opened. With off, it never asks by itself, and the on-screen controller and a phone still play the sketch.

OAVp5.connectHardware() asks whatever the option says, and OAVp5.hardware tells you the state: 'off' until it has been asked.

Type
String
Values
auto | click | off
default
auto (click in Strudel)

Only auto and click ask. Any other value acts like off.

Notes

  • On strudel.cc (or a page where Strudel's own functions are present) the default is click, because Strudel's midin() asks for MIDI itself. Setting hardware yourself wins.
  • Safari and iPad have no Web MIDI at all: when oav-p5 asks (or you call OAVp5.connectHardware()), the state there becomes 'unavailable'.
  • Set it before oav-p5 loads. window.OAV_P5 = { hardware: … }; above the loader line wins, then ?oav_hardware=… on the page address, then ?hardware=… on the script's own URL. Values in window.OAV_P5 are turned into text, so write 'off', not false. On OpenProcessing the page address takes ?sketch_oav_hardware=… (the project's README says OpenProcessing forwards it to the sketch).

Examples

jsOpenProcessing ↗
window.OAV_P5 = { hardware: 'click' };

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

function draw() {
  background(20);
  fill(255);
  text('hardware option: ' + OAVp5.options.hardware, 20, 30);
  text('Web MIDI state: ' + OAVp5.hardware, 20, 60);   // stays "off" until you open the 🎹 panel
}
The page does not ask for Web MIDI when it loads, and the state stays "off". Press 🎹: that opens the panel and asks. Delete the first line and it asks at once.

Related

  • OAVp5.hardware Where Web MIDI stands: 'off', 'asking', 'connected', 'waiting', 'denied' or 'unavailable'.
  • OAVp5.connectHardware() Asks the browser for Web MIDI now, and returns a promise that says whether a real controller can be heard.
  • OAVp5.devices The names of the MIDI controllers plugged in, as the browser reports them: an array of text, empty when there is none.
  • panel Whether the 🎹 panel starts shut, open, or does not exist: closed, open or off.
  • strudel Whether oav-p5 treats the page as Strudel, the live-coding editor, and behaves politely beside it: auto, on or off.

p5/oav-p5.js, line 126

↑ Back to top · All names