JZZ.js enables Web MIDI API in Node.js and those browsers that don't support it natively.
Just include it in your project and start using navigator.requestMIDIAccess().
navigator.requestMIDIAccess() - get the MIDIAccess object.
It's either the native MIDIAccess object if the browser supports Web MIDI API, or a JZZ implementation otherwise.
JZZ.requestMIDIAccess() - get the JZZ implementation of MIDIAccess object.
In Node.js and browsers without native Web MIDI API support, both navigator.requestMIDIAccess() and JZZ.requestMIDIAccess() return the same object.
In browsers with native Web MIDI API support, the former returns the native MIDIAccess object, while the later returns the JZZ implementation.
JZZ version may offer more (virtual) MIDI ports, such as JZZ.input.Kbd or JZZ.synth.OSC.
// HTML <script src="JZZ.js"></script> <script><!-- navigator.requestMIDIAccess().then(function(webmidi) { webmidi.outputs.forEach(function(port) { console.log('MIDI Out:', port.name); }); webmidi.inputs.forEach(function(port) { console.log('MIDI In:', port.name); }); }, function(err) { console.log('Cannot start WebMIDI!'); if (err) console.log(err); } ); --></script>
// Node.js var navigator = require('jzz'); navigator.requestMIDIAccess().then(function(webmidi) { webmidi.outputs.forEach(function(port) { console.log('MIDI Out:', port.name); }); webmidi.inputs.forEach(function(port) { console.log('MIDI In:', port.name); }); navigator.close(); // Required in Node.js. // This will close MIDI inputs, otherwise Node.js will wait for MIDI input forever. }, function(err) { console.log('Cannot start WebMIDI!'); if (err) console.log(err); } );