Skip to content

Instantly share code, notes, and snippets.

@urish
Created December 21, 2018 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urish/5e433ae94fdd55b62cd85871abd3a2cf to your computer and use it in GitHub Desktop.
Save urish/5e433ae94fdd55b62cd85871abd3a2cf to your computer and use it in GitHub Desktop.
(async function() {
const midi = await navigator.requestMIDIAccess();
const midiOutput = Array.from(midi.outputs.values())
.find(o => o.name.includes('Teensy'));
const midiInput = Array.from(midi.inputs.values())
.find(o => o.name.includes('Keystation'));
// Forward all MIDI events from Keyboard to trumpet
midiInput.onmidimessage = ({data}) =>
midiOutput.send([data[0], data[1], data[2] ? 127 : 0]);
})().catch(console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment