The Output class allows you to send MIDI messages to a physical or virtual MIDI port.
Message Types and Arguments:
noteon / noteoff: { note, velocity, channel }cc: { controller, value, channel }poly aftertouch: { note, pressure, channel }channel aftertouch: { pressure, channel }program: { number, channel }pitch / position: { value, channel } (where value is 0-16383)mtc: { type, value }select: { song }sysex: { bytes } (must be an array starting with 0xf0 and ending with 0xf7)
To open a physical port, pass the name from getOutputs(). To create a virtual port, pass true as the second argument.
const { Output, getOutputs } = require('@julusian/midi');
// Open a physical output port
const output = new Output('Your MIDI Output Name');
// Send a Note On message
output.send('noteon', { note: 60, velocity: 127, channel: 0 });
// Send a CC message
output.send('cc', { controller: 7, value: 100, channel: 0 });
// Send a Sysex message
output.send('sysex', { bytes: [0xf0, 0x01, 0x02, 0xf7] });