Last active
August 8, 2017 20:25
-
-
Save alexeybondarenko/2e5f9a264610064ba10772162b2611b3 to your computer and use it in GitHub Desktop.
Tutorial. How to create MIDI synthesizer with MIDI API and Node JS https://medium.com/nebo-15/tutorial-how-to-create-midi-synthesizer-with-midi-api-and-node-js-48d41c162009
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() { | |
'use strict'; | |
console.log('App is running'); | |
var midiAccess = null; | |
navigator.requestMIDIAccess().then(onMidiAccessSuccess, onMidiAccessFailure); | |
function onMidiAccessSuccess(access) { | |
midiAccess = access; | |
var inputs = midiAccess.inputs; | |
var inputIterators = inputs.values(); | |
var firstInput = inputIterators.next().value; | |
if (!firstInput) return; | |
firstInput.onmidimessage = handleMidiMessage; | |
} | |
function onMidiAccessFailure(error) { | |
console.log('Oops. Something were wrong with requestMIDIAccess', error.code); | |
} | |
function handleMidiMessage(e) { | |
console.log(e); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment