-
-
Save sc0ttj/08ff0c1deda245dd61faa8da3bf55dd8 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 hidden or 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