generic-midi-controller
A common interface for handling different MIDI controller input/output devices using the Web MIDI API.
Usage
controller = GenericMIDI(input, output)
Creates a Controller
instance. Input/output handling is customizable using the input
and output
functions:
input
An object where each property contains an array of functions for determining updated values on receiving MIDI input messages. Optional.
const controller =
The above controller listens to events for value changes on inputs 72 through 75. Note that null
is returned when a value should not be updated.
Once set up as such, the following should be possible:
controller// ...after receiving some MIDI messages:controllerinputsbuttons0 // 127controllerinputsbuttons1 // 24controllerinputsbuttons2 // 0controllerinputsbuttons3 // 38
output
An object where each property contains an array of functions for triggering output MIDI messages using send
. Optional.
const controller =
Once set up as such, the following should be possible:
controllercontrolleroutputsbuttons0 = 127 // sends "127" to button 0controlleroutputsbuttons1 = 24 // sends "24" to button 1controlleroutputsbuttons2 = 0 // sends "0" to button 2controlleroutputsbuttons3 = 38 // sends "38" to button 3
controller.setInput(input)
Sets the input MIDI device.
controller.setOutput(output)
Sets the output MIDI device.
navigator
controller.on('input', fn(group, i, value))
Fired whenever an input
message is received and handled:
controller
controller.on('output', fn(group, i, value))
Fired whenever an output
update is triggered:
controller
See Also
License
MIT. See LICENSE.md for details.