midi-grid
Map a duplex midi stream to observable input and output value grids.
For modelling grid midi controllers such as the Launchpad.
npm
Install via$ npm install midi-grid
API
var MidiGrid =
var midiGrid = MidiGrid(duplexMidiStream, mapping[, outputGrid])
Create an observable instance of MidiGrid.
Pass in a duplexMidiStream
such as web-midi or midi-stream.
mapping
is an array-grid containing the midi to map (e.g. "144/36"
).
Optionally pass in outputGrid
- an observable grid for setting output values as observ-grid or observ-grid-stack for layering grids.
// observe Novation Launchpad button gridvar MidiStream = var duplexPort = var mapping = for var r=0;r<8;r++ for var c=0;c<8;c++ var launchpadButtonId = r * 16 + c mapping var launchpad =
midiGrid.get(row, col)
Get the current input value of the given coordinates.
midiGrid.set(row, col, value)
Alias for output.set(row, col, value)
. Sets the output value at the given coordinates.
midiGrid.resend()
Resend all the current output values. Use if you switch the output device and want to resend all state.
midiGrid.midiStream (Duplex Stream)
This midi stream is connected to the constructor duplexPort
if specified, otherwise it can be manually piped to and from a midi device.
Observable Attributes
midiGrid
Notifies when any input value changes (e.g. a button is pressed/released).
midiGrid.output
(ObservGrid or custom observ passed to ctor)
Notifies when any output value changes (e.g. light up button). Set output values using midiGrid.output.set(row, col, val)
or use the alias midiGrid.set
.