diff --git a/index.html b/index.html index fdd30a4..c14af0b 100644 --- a/index.html +++ b/index.html @@ -2423,13 +2423,11 @@ function startWebMIDI(){ let notesPlaying = {} let synth function webMidiStarted(){ - let midiStarted = Date.now() - console.log("WebMidi enabled!") - synth = new Tone.Synth().toDestination() - //let myInput = WebMidi.getInputByName("MPK mini Play mk3"); // on Quest 2 - let myInput = WebMidi.getInputByName("MPK mini Play mk3:MPK mini Play mk3"); // on desktop - WebMidi.inputs.forEach(input => console.log(input.manufacturer, input.name)); + console.log("WebMidi enabled!", WebMidi.inputs) + let myInput = WebMidi.inputs.filter(i => i.name.match("MPK mini Play mk3"))?.[0] + if (!myInput){ console.log("missing mk3 keyboard"); return;} const keyboard = myInput.channels[1] + synth = new Tone.Synth().toDestination() keyboard.addListener("noteon", e => { let identifierNoOctave = e.note.identifier.slice(0,-1) let pos = ""+ (Object.getOwnPropertyNames(notes).indexOf(identifierNoOctave)/40+e.note.octave/3.3-1.1)+ " 1.5 -.1" @@ -2444,7 +2442,6 @@ function webMidiStarted(){ setInterval( _=> pushBackClass("musicalnote", .001), 10) const pads = myInput.channels[10] - pads.addListener("noteon", e => { let identifierNoOctave = e.note.identifier.slice(0,-1) let audio = new Audio(drumkitBaseURL+drumKit[identifierNoOctave])