Created
October 11, 2015 20:40
-
-
Save lukewestby/21ec4489e6ab0e51f5b3 to your computer and use it in GitHub Desktop.
Get MIDI input and output devices from the Web MIDI API by name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findMidiDevices(name) { | |
return navigator | |
.requestMIDIAccess() | |
.then((midiAccess) => { | |
let input, output; | |
midiAccess.inputs.forEach((currentInput) => { | |
if(currentInput.name === name) input = currentInput; | |
}); | |
midiAccess.outputs.forEach((currentOutput) => { | |
if(currentOutput.name === name) output = currentOutput; | |
}) | |
return { input, output }; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment