MidiOutput class public functions

MidiOutput
~MidiOutput
NRPN
NRPN_attack
NRPN_decay
NRPN_drumAttack
NRPN_drumChorus
NRPN_drumDecay
NRPN_drumFilterCutoff
NRPN_drumFilterResonance
NRPN_drumLevel
NRPN_drumPan
NRPN_drumPitch
NRPN_drumReverb
NRPN_drumVariation
NRPN_filterCutoff
NRPN_null
NRPN_release
NRPN_vibratoDelay
NRPN_vibratoDepth
NRPN_vibratoRate
RPN
RPN_null
coarseTune
cont
fineTune
off
pbRange
pc
play
pw
recordStart
recordStop
reset
send
silence
sustain
sysex
tuneCoarse
tuneFine
tuningBank
tuningProgram
An index of inherited functions can be found at the bottom of this page.
MidiOutput(void);
Calls MidiOutPort().

MidiOutput(int aPort, int autoOpen = 1);
Opens MIDI port aPort automatically if openAuto == 1. If the port is already open, will not try to reopen it.

~MidiOutput();
Does nothing.

Basic user MIDI output commands:

Common MIDI Commands for playing synthesizers:
int cont(int channel, int controller, int data);
Sends the value for the MIDI continuous controller command (0xb0) on the specified MIDI channel. Here is a list of continuous controllers.

int off(int channel, int keynum, int releaseVelocity);
Sends a note off command using midi command 0x80 with the specified key number and release velocity. Note that the most common way of turning off a note is to send the note-on command (0x90) with an attack velocity of 0 (see the play function.

int pc(int channel, int timbre);
Sends a MIDI patch change which changes the timbre on the specified channel. If you want to change to a timbre greater than 127, then check how your synthesizer does this. Usually, timbres are organized into banks, and you specify first which bank with the continuous controller #0.

int play(int channel, int keynum, int velocity);
Sends a note on or note off on the specified channel. If velocity parameter is missing, then a note off command is sent.

int pw(int channel, int mostByte, int leastByte);
Sends pitch wheel information on the specified MIDI channel. For the three parameter version, the mostByte = coarse tuning values 0..127 which are the most significant 7 bits of a tuning value, and the fine tuning values (leastByte) 0..127 are the least significant 7 bits of a tuning value. For the two parameter version, tuningData is a 14 bit number.

int pw(int channel, int tuningData);
Sends pitch wheel information on the specified MIDI channel. For the three parameter version, the mostByte = coarse tuning values 0..127 which are the most significant 7 bits of a tuning value, and the fine tuning values (leastByte) 0..127 are the least significant 7 bits of a tuning value. For the two parameter version, tuningData is a 14 bit number.

int pw(int channel, double tuningData);
Converts a number in the range from -1.0 to +1.0 into a 14 byte number which is sent out with the pitch wheel command.

void recordStart(char *filename, int format);
Starts recording MIDI output to the file filename according to the specified format which defaults to ascii. MIDI output sent through the send command are recorded, which output send through the rawsend command are not recorded. If the file already exists, the file will be overwritten. The defined formats are: Here is a description of the formats for recording MIDI output.

void recordStop(void);
Stops recording MIDI output to the file specified with recordStart.

void reset(void);
sends the MIDI command 0xFF which should force the MIDI devices on the other side of the MIDI cable (which is connected to the port of the MidiOutput object) into their power-on reset condition, clear running status, turn off any sounding notes, set Local Control on, and otherwise clean up the state of things.

int send(int command, int p1, int p2);
Sends MIDI data from the computer to a synthesizer. If not recording, then just calls rawsend . If recording, bytes are stored in an output buffer until the buffer is supposed to be flushed. Then the time since the previous flush is calculated and recorded, as well as all the bytes in the output buffer.

int send(int command, int p1);
Sends MIDI data from the computer to a synthesizer. If not recording, then just calls rawsend . If recording, bytes are stored in an output buffer until the buffer is supposed to be flushed. Then the time since the previous flush is calculated and recorded, as well as all the bytes in the output buffer.

int send(int command);
Sends MIDI data from the computer to a synthesizer. If not recording, then just calls rawsend . If recording, bytes are stored in an output buffer until the buffer is supposed to be flushed. Then the time since the previous flush is calculated and recorded, as well as all the bytes in the output buffer.

void silence(int aChannel = -1);
silence MIDI data from the computer to a synthesizer. If channel == -1, then send note off commands on all channels, otherwise send only on specified channel.

void sustain(int channel, int status);
Turns on/off the continuous controller 0x40 (sustain). Turn on sustain with sustain(1). Turn off sustain with sustain(0). Same as off=cont(channel, 0x40, 0), or on=cont(channel, 0x40, 127).

Other useful basic commands

int sysex(char* data, int length);
Sends a system exclusive MIDI message. you must supply the 0xf0 at the start of the array and the 0xf7 at the end of the array.

int sysex(uchar* data, int length);
Sends a system exclusive MIDI message. you must supply the 0xf0 at the start of the array and the 0xf7 at the end of the array.

NRPN controller functions

Description of RPN and NRPNs
int NRPN(int channel, int nrpn_msb, int nrpn_lsb, int data_msb, int data_lsb);
NRPN -- sends a Non-registered parameter number.

int NRPN(int channel, int nrpn_msb, int nrpn_lsb, int data_msb);
NRPN -- sends a Non-registered parameter number.

int NRPN(int channel, int nrpn_msb, int nrpn_lsb, double data);
NRPN -- sends a Non-registered parameter number.

Convenience functions for use of NRPN function are given below. Note that these are Non-Registered Parameter Numbers which means that each synthesizer manufacture can do whatever they want, so these functions might not behave the way you expect them to do so. Yamaha XG and Roland GS NRPN specifications are given below.
int NRPN_null(int channel);
Same as NRPN(channel, 127, 127, 0); a NULL RPN will disable the previous values of either RPN or NRPN data.

int NRPN_attack(int channel, double value);
Same as NRPN(channel, 1, 99, value); with value in the range from -1.0 to +1.0.

int NRPN_attack(int channel, int value);
Same as NRPN(channel, 1, 99, value+64); with value in the range -64 to +63.

int NRPN_decay(int channel, double value);
Same as NRPN(channel, 1, 100, value); with value in the range from -1.0 to +1.0.

int NRPN_decay(int channel, int value);
Same as NRPN(channel, 1, 100, value+64); with value in the range -64 to +63.

int NRPN_drumAttack(int drum, double value);
Same as NRPN(9, 22, drum, value); with value in the range -1.0 to +1.0.

int NRPN_drumAttack(int drum, int value);
Same as NRPN(9, 22, drum, value+64); with value in the range from -64 to +63.

int NRPN_drumChorus(int drum, double value);
Same as NRPN(9, 30, drum, value); with value in the range from -1.0 to +1.0.

int NRPN_drumChorus(int drum, int value);
Same as NRPN(9, 30, drum, value); with value in the range from -64 to +63.

int NRPN_drumDecay(int drum, double value);
Same as NRPN(9, 23, drum, value); with value in the range from -1.0 to +1.0.

int NRPN_drumDecay(int drum, int value);
Same as NRPN(9, 23, drum, value); with value in the range from -64 to +63.

int NRPN_drumLevel(int drum, double value);
Same as NRPN(9, 26, drum, value); with value in the range from -1.0 to +1.0.

int NRPN_drumLevel(int drum, int value);
Same as NRPN(9, 26, drum, value); with value in the range from -64 to +63.

int NRPN_drumPan(int drum, double value);
Same as NRPN(9, 28, drum, value); with value in the range from -1.0 to +1.0.

int NRPN_drumPan(int drum, int value);
Same as NRPN(9, 28, drum, value); with value in the range from -64 to +63.

int NRPN_drumPitch(int drum, double value);
Same as NRPN(9, 24, drum, value); with value in the range from -1.0 to +1.0.

int NRPN_drumPitch(int drum, int value);
Same as NRPN(9, 24, drum, value); with value in the range from -64 to +63.

int NRPN_drumFilterCutoff(int drum, double value);
Same as NRPN(9, 20, drum, value); with value in the range from -1.0 to +1.0.

int NRPN_drumFilterCutoff(int drum, int value);
Same as NRPN(9, 20, drum, value); with value in the range from -64 to +63.

int NRPN_drumFilterResonance(int drum, double value);
Same as NRPN(9, 21, drum, value); with value in the range from -1.0 to +1.0.

int NRPN_drumFilterResonance(int drum, int value);
Same as NRPN(9, 21, drum, value); with value in the range from -64 to +63.

int NRPN_drumReverb(int drum, double value);
Same as NRPN(9, 29, drum, value); with value in the range from -1.0 to +1.0.

int NRPN_drumReverb(int drum, int value);
Same as NRPN(9, 29, drum, value); with value in the range from -64 to +63.

int NRPN_drumVariation(int drum, double value);
Same as NRPN(9, 31, drum, value); with value in the range from -1.0 to +1.0.

int NRPN_drumVariation(int drum, int value);
Same as NRPN(9, 31, drum, value); with value in the range from -64 to +63.

int NRPN_filterCutoff(int channel, double value);
Same as NRPN(9, 1, 33, value); with value in the range from -1.0 to +1.0.

int NRPN_filterCutoff(int channel, int value);
Same as NRPN(9, 1, 33, value+64); with value in the range from -64 to +63.

int NRPN_release(int channel, double value);
Same as NRPN(channel, 1, 102, value); with value in the range from -1.0 to +1.0.

int NRPN_release(int channel, int value);
Same as NRPN(channel, 1, 102, value+64); with value in the range from -64 to 63.

int NRPN_vibratoDelay(int channel, double value);
Same as NRPN(channel, 1, 32, value); with value in the range from -1.0 to +1.0.

int NRPN_vibratoDelay(int channel, int value);
Same as NRPN(channel, 1, 32, value+64); with value in the range from -64 to 63.

int NRPN_vibratoDepth(int channel, double value);
Same as NRPN(channel, 1, 9, value); with value in the range from -1.0 to +1.0.

int NRPN_vibratoDepth(int channel, int value);
Same as NRPN(channel, 1, 9, value+64); with value in the range from -64 to 63.

int NRPN_vibratoRate(int channel, double value);
Same as NRPN(channel, 1, 8, value); with value in the range from -1.0 to +1.0.

int NRPN_vibratoRate(int channel, int value);
Same as NRPN(channel, 1, 8, value+64); with value in the range from -64 to 63.

RPN functions

Description of RPN and NRPNs
int RPN(int channel, int rpn_msb, int rpn_lsb, int data_msb, int data_lsb);
Sends a registered parameter number.

int RPN(int channel, int rpn_msb, int rpn_lsb, int data_msb);
Sends a registered parameter number.

int RPN(int channel, int rpn_msb, int rpn_lsb, double data);
Sends a registered parameter number.

int RPN_null(void);
Same as RPN(channel, 127, 127, 0);. After making the necessary settings you should set RPN's to NULL to reduce the risk of operational errors. a NULL RPN will disable the previous values of either RPN or NRPN data.

int RPN_null(int channel);
Same as RPN(channel, 127, 127, 0);. After making the necessary settings you should set RPN's to NULL to reduce the risk of operational errors. a NULL RPN will disable the previous values of either RPN or NRPN data.

int pbRange(int channel, int steps);
Same as RPN(channel, 0, 0, steps); Default value for pitch bend sensitivity is 2 steps (semi-tones).

int tuneFine(int channel, int cents);
Same as RPN(channel, 0, 1, cents+64); cents in the range from -64 to +63.

int fineTune(int channel, int cents);
Same as tuneFine(channel, cents);

int tuneCoarse(int channel, int steps);
Same as RPN(channel, 0, 1, steps+64); steps in the range from -64 to +63.

int coarseTune(int channel, int steps);
Same as tuneCoarse(channel, steps);

int tuningProgram(int channel, int program);
Same as RPN(channel, 0, 3, program);

int tuningBank(int channel, int bank);
Same as RPN(channel, 0, 4, bank);


Functions inherited from MidiOutPort:
MidiOutPort
~MidiOutPort
close
closeAll
getChannelOffset
getName
getNumPorts
getPort
getPortStatus
getTrace
open
rawsend
setAndOpenPort
setChannelOffset
setPort
setTrace
sysex
toggleTrace