Skip to content

Instantly share code, notes, and snippets.

@sc0ttj
Forked from lukewestby/findMidiDevices.js
Created June 12, 2025 08:58
Show Gist options
  • Save sc0ttj/08ff0c1deda245dd61faa8da3bf55dd8 to your computer and use it in GitHub Desktop.
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
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