Skip to content

Instantly share code, notes, and snippets.

@konsumer
Last active February 5, 2020 21:45
Show Gist options
  • Select an option

  • Save konsumer/33b93d9fba4dc606e00bc71e0e7f8112 to your computer and use it in GitHub Desktop.

Select an option

Save konsumer/33b93d9fba4dc606e00bc71e0e7f8112 to your computer and use it in GitHub Desktop.
// npm i easymidi esm && node -r esm simple_midi_forwarder.js
import { Input, Output, getInputs, getOutputs } from 'easymidi'
// these are lists of available devices
const inputs = getInputs()
const outputs = getOutputs()
console.log({ inputs, outputs })
// these will depend on your setup
const input = new Input(inputs[1])
const output = new Output(outputs[0])
const handler = ({ _type, ...params }) => {
output.send(_type, params)
}
input.on('noteon', handler)
input.on('noteoff', handler)
input.on('poly', handler)
input.on('cc', handler)
input.on('program', handler)
input.on('channel', handler)
input.on('pitch', handler)
input.on('position', handler)
input.on('mtc', handler)
input.on('select', handler)
input.on('clock', handler)
input.on('start', handler)
input.on('continue', handler)
input.on('stop', handler)
input.on('reset', handler)
input.on('sysex', handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment