/** * MIDI * @module midi.js; */ import { WebMidi } from "webmidi"; function enable(play) { WebMidi.enable() .then(onEnabled) .catch((error) => console.error(error)); // Function triggered when WEBMIDI.js is ready function onEnabled() { // Display available MIDI input devices if (WebMidi.inputs.length < 1) { console.log("No device detected."); return; } else { WebMidi.inputs.forEach((device, index) => { document.body.innerHTML += `${index}: ${device.name}
`; }); const mySynth = WebMidi.inputs[0]; // const mySynth = WebMidi.getInputByName("TYPE NAME HERE!") mySynth.channels[1].addListener("noteon", (event) => { console.log(event.note); }); } } } export default { enable };