1.3.2 • Published 10 years ago

midi-stream v1.3.2

Weekly downloads
3
License
ISC
Repository
github
Last release
10 years ago

midi-stream

Duplex stream wrapper around midi module.

When required from the browser (using browserify) web-midi is returned instead.

Install

$ npm install midi-stream

Example

var MidiStream = require('midi-stream')

var duplex = MidiStream('Launchpad', 0)

// clear lights
duplex.write([176, 0, 0])

// echo back the message to launchpad
duplex.pipe(duplex) 

// write buttons pressed to console
duplex.on('data', function(data){
  console.log(data)
})

// paint a face after 10 seconds :)
var faceCoords = [
  [1,1], [2,1], [5,1], [6,1],
  [1,2], [2,2], [5,2], [6,2],
  [2,4], [5,4],
  [2,5], [3,5], [4,5], [5,5]
]

setTimeout(function(){
  faceCoords.forEach(function(xy){
    var id = xy[1] * 16 + xy[0] // convert coords to midi note
    duplex.write([144, id, 60])
  })
}, 10000)

// wait 20 seconds then close the port
setTimeout(function(){
  duplex.end()
}, 20000)


///// bonus round, second launchpad! ////
var bonus = MidiStream('Launchpad', 1)
faceCoords.forEach(function(xy){
  var id = xy[1] * 16 + xy[0] // convert coords to midi note
  bonus.write([144, id, 60])
})
1.3.2

10 years ago

1.3.1

10 years ago

1.3.0

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.2

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago

0.0.0

11 years ago