JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 60
  • Score
    100M100P100Q77192F
  • License MIT

Web MIDI API stream based wrapper

Package Exports

  • web-midi

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (web-midi) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

web-midi

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

It is currently only available in Chrome Canary requiring #enable-experimental-web-platform-features and #enable-web-midi) flags.

Can be used in older browsers if WebMIDIAPIShim is included on your html page.

Install

$ npm install web-midi

Example

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)

Or create a duplex stream (assumes input and output ports are named the same thing)

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)