web-midi

Web MIDI API stream based wrapper

web-midi

This module wraps the Web MIDI API into a stream interface.

It is currently only implemented in Chrome requiring the #enable-web-midi) flag.

Can potentially be used in older browsers with the WebMIDIAPIShim.

For a serverside (Node) based version of the same API check out midi-stream.

$ npm install web-midi
var midi = require('web-midi')
var inStream = midi.openInput('Launchpad')
var outStream = midi.openOutput('Launchpad')
 
inStream.on('data', function(data){
  // => [146, 32, 127] 
})
 
// send on note 
outStream.write([146, 38, 127])
 
setTimeout(function(){
  // off note 
  outStream.write([146, 38, 0])
}, 1000)
 
// or use pipes 
var anotherStream = midi.openOutput('IAC')
inStream.pipe(anotherStream)
var midi = require('web-midi')
 
var duplexStream = midi('Launchpad')
 
duplexStream.on('data', function(data){
  // => [146, 32, 127] 
})
 
// send on note 
duplexStream.write([146, 38, 127])
 
setTimeout(function(){
  // send off note 
  duplexStream.write([146, 38, 0])
}, 1000)
 
// or use pipes 
var anotherStream = midi('IAC')
duplexStream.pipe(anotherStream)