This commit is contained in:
Felix Roos 2022-03-21 19:50:47 +01:00
parent 98f91607cd
commit 4487834591
15 changed files with 452 additions and 520 deletions

9
docs/dist/midi.js vendored
View file

@ -37,7 +37,14 @@ Pattern.prototype.midi = function(output, channel = 1) {
if (!WebMidi.outputs.length) {
throw new Error(`🔌 No MIDI devices found. Connect a device or enable IAC Driver.`);
}
const device = output ? outputByName(output) : WebMidi.outputs[0];
let device;
if (typeof output === "number") {
device = WebMidi.outputs[output];
} else if (typeof output === "string") {
device = outputByName(output);
} else {
device = WebMidi.outputs[0];
}
if (!device) {
throw new Error(`🔌 MIDI device '${output ? output : ""}' not found. Use one of ${WebMidi.outputs.map((o) => `'${o.name}'`).join(" | ")}`);
}