shim#
optionoav-p5?oav_shim=on | off
Whether oav-p5 replaces navigator.requestMIDIAccess so sketches with their own Web MIDI code also hear the 🎹 and phones: on or off.
With on, a sketch that calls navigator.requestMIDIAccess() itself (WebMidi.js does) gets the real ports and one more input called "OAV Virtual MIDI", which carries whatever the on-screen controller and the phone play. It also works in Safari and on iPad, where there is no Web MIDI: the sketch gets the virtual port alone, so a WebMidi.js sketch still runs there. Programs can play into its output as well (Strudel's .midi('OAV Virtual MIDI')).
off leaves the browser's own requestMIDIAccess alone. Use it when a page already has its own MIDI handling that must not see an extra port.
- Type
String- Values
on | off- default
on
Only off turns it off.
Notes
- Order matters: oav-p5 has to load before the code that asks for MIDI, which is why the loader line goes first. A page that opened MIDI earlier keeps the browser's own answer, and 🩺 says so.
- Set it before oav-p5 loads.
window.OAV_P5 = { shim: … };above the loader line wins, then?oav_shim=…on the page address, then?shim=…on the script's own URL. Values inwindow.OAV_P5are turned into text, so write'off', notfalse. On OpenProcessing the page address takes?sketch_oav_shim=…(the project's README says OpenProcessing forwards it to the sketch).
Examples
window.OAV_P5 = { shim: 'off' };
let names = 'asking…';
function setup() {
createCanvas(400, 300);
navigator.requestMIDIAccess().then(
(access) => { names = [...access.inputs.values()].map((i) => i.name).join(', ') || 'no inputs'; },
(error) => { names = 'refused: ' + error.name; }
);
}
function draw() {
background(20);
fill(255);
text('shim: ' + OAVp5.options.shim, 20, 30);
text('MIDI inputs: ' + names, 20, 60);
}Related
OAVp5.input()Sends one MIDI message into oav-p5 by hand, as bytes: the whole sketch reacts as if a controller had sent it.hardwareWhen oav-p5 asks the browser for Web MIDI, which a real controller needs:autoat load,clickwhen the 🎹 panel opens, oroff.midiMessage()You define this function; oav-p5 calls it for every MIDI message it receives, with the raw bytes and where they came from.OAVp5.lastThe latest note, control change or pitch bend that arrived: its type, number, value, channel, where it came from and which control it is.nullbefore any.