The MidiEvent class is a MidiMessage plus an added timestamp public variable, .tick. The MidiEvent class also adds other support variables such as .track which store the track number in the MIDI file that the MidiEvent occurs in.
Public functions
getDurationInSeconds — Get the duration of a note in seconds.
getLinkedEvent — Returns a linked event (such as for note-on/note-off pair).
getTickDuration — Get the duration of a note in terms of MIDI ticks.
isLinked — Returns true of the message is linked to another event.
linkEvent — Links one event with another (such as note-ons/note-offs).
operatorEQUALS — Copy the contents of another MidiEvent or MidiMessage.
unlinkEvent — Disassociates any MidiEvents linked to this one.
Functions inherited from MidiMessage
isNoteOff — Return true if MIDI message is a note off message.
int isNoteOff(void);
Return true if command nibble is 0x80, or command nibble is 0x90 and key velocity is 0.
Return true if command nibble is 0x80, or command nibble is 0x90 and key velocity is 0.
Source code for isNoteOff on GitHub
////////////////////////////// // // MidiMessage::isNoteOff -- Returns true if the command nibble is 0x80 // or if the command nibble is 0x90 with p2=0 velocity. // int MidiMessage::isNoteOff(void) { if (size() != 3) { return 0; } else if (((*this)[0] & 0xf0) == 0x80) { return 1; } else if ((((*this)[0] & 0xf0) == 0x90) && ((*this)[2] == 0)) { return 1; } else { return 0; } }
isNoteOn — Returns true if MIDI message is a note-on message.
int isNoteOn(void);
Returns true if MIDI message is a note-on message.
Returns true if MIDI message is a note-on message.
Source code for isNoteOn on GitHub
////////////////////////////// // // MidiMessage::isNoteOn -- Returns true if the command byte is in the 0x90 // range and the velocity is non-zero // int MidiMessage::isNoteOn(void) { if (size() != 3) { return 0; } else if (((*this)[0] & 0xf0) != 0x90) { return 0; } else if ((*this)[2] == 0) { return 0; } else { return 1; } }
isAftertouch — Returns true if MIDI message is an aftertouch message.
int isAftertouch(void);
Returns true if command nibble is 0xA0 for an aftertouch message.
Returns true if command nibble is 0xA0 for an aftertouch message.
Source code for isAftertouch on GitHub
////////////////////////////// // // MidiMessage::isAftertouch -- Returns true if the command byte is in the 0xA0 // range. // int MidiMessage::isAftertouch(void) { if (size() != 3) { return 0; } else if (((*this)[0] & 0xf0) != 0xA0) { return 0; } else { return 1; } }
isController — Returns true if MIDI message is an controller message.
int isController(void);
Returns true if command nibble is 0xB0 for an continuous controller.
Returns true if command nibble is 0xB0 for an continuous controller.
Source code for isController on GitHub
////////////////////////////// // // MidiMessage::isController -- Returns true if the command byte is in the 0xB0 // range. // int MidiMessage::isController(void) { if (size() != 3) { return 0; } else if (((*this)[0] & 0xf0) != 0xB0) { return 0; } else { return 1; } }
isTimbre — Returns true if MIDI message is a patch change.
int isTimbre(void);
Returns true if MIDI message is a patch change.
Returns true if MIDI message is a patch change.
Source code for isTimbre on GitHub
////////////////////////////// // // MidiMessage::isTimbre -- Returns true of a patch change message // (command nibble 0xc0). // int MidiMessage::isTimbre(void) { if (((*this)[0] & 0xf0) != 0xc0) { return 0; } else if (size() != 2) { return 0; } else { return 1; } } int MidiMessage::isPatchChange(void) { return isTimbre(); }
isPressure — Returns true if MIDI message is an channel pressure message.
int isPressure(void);
Returns true if command nibble is 0xD0 for an channel pressure message.
Returns true if command nibble is 0xD0 for an channel pressure message.
Source code for isPressure on GitHub
////////////////////////////// // // MidiMessage::isPressure -- Returns true of a channel pressure message // (command nibble 0xd0). // int MidiMessage::isPressure(void) { if (((*this)[0] & 0xf0) != 0xd0) { return 0; } else if (size() != 2) { return 0; } else { return 1; } }
isPitchbend — Returns true if MIDI message is an pitch-bend message.
int isPitchbend(void);
Returns true if command nibble is 0xE0 for an pitch-bend message.
Returns true if command nibble is 0xE0 for an pitch-bend message.
Source code for isPitchbend on GitHub
////////////////////////////// // // MidiMessage::isPitchbend -- Returns true of a pitch-bend message // (command nibble 0xe0). // int MidiMessage::isPitchbend(void) { if (((*this)[0] & 0xf0) != 0xe0) { return 0; } else if (size() != 3) { return 0; } else { return 1; } }
getChannelNibble — Return channel number of the MIDI command byte (offset from 0).
int getChannelNibble(void);
Return the bottom 4 bits of the command byte for the MIDI message.
Return the bottom 4 bits of the command byte for the MIDI message.
Source code for getChannelNibble on GitHub
////////////////////////////// // // MidiMessage::getChannelNibble -- Returns the bottom 4 bites of the // (*this)[0] entry, or -1 if there is not (*this)[0]. Should be refined // to return -1 if the top nibble is 0xf0, since those commands are // not channel specific. // int MidiMessage::getChannelNibble(void) { if (size() < 1) { return -1; } else { return (*this)[0] & 0x0f; } } int MidiMessage::getChannel(void) { return getChannelNibble(); }
setChannelNibble — Set the channel nibble in a MIDI message command byte.
void setChannelNibble(int channel);
Set the channel nibble in a MIDI message command byte.
Set the channel nibble in a MIDI message command byte.
Source code for setChannelNibble on GitHub
////////////////////////////// // // MidiMessage::setChannelNibble -- // void MidiMessage::setChannelNibble(int value) { if (this->size() < 1) { this->resize(1); } (*this)[0] = ((*this)[0] & 0xf0) | ((uchar)(value & 0x0f)); } void MidiMessage::setChannel(int value) { setChannelNibble(value); }
setCommand — Set the command byte and any parameters for a message.
void setCommand(int value);
void setCommand(int value, int p1);
void setCommand(int value, int p1, int p2);
Set the command byte and any parameters for a message. The size of the message will be adjusted to the number of input parameters.
void setCommand(int value, int p1);
void setCommand(int value, int p1, int p2);
Set the command byte and any parameters for a message. The size of the message will be adjusted to the number of input parameters.
Source code for setCommand on GitHub
////////////////////////////// // // MidiMessage::setCommand -- Set the command byte and parameter bytes // for a MidiMessage. The size of the message will be adjusted to // the number of input parameters. // void MidiMessage::setCommand(int value, int p1) { this->resize(2); (*this)[0] = (uchar)value; (*this)[1] = (uchar)p1; } void MidiMessage::setCommand(int value, int p1, int p2) { this->resize(3); (*this)[0] = (uchar)value; (*this)[1] = (uchar)p1; (*this)[2] = (uchar)p2; }
getCommandByte — Return the command byte of the MIDI message.
int getCommandByte(void);
Return the command byte of the MIDI message.
Return the command byte of the MIDI message.
Source code for getCommandByte on GitHub
////////////////////////////// // // MidiMessage::getCommandByte -- Return the command byte or -1 if not // allocated. // int MidiMessage::getCommandByte(void) { if (size() < 1) { return -1; } else { return (*this)[0]; } }
setCommandByte — Set the command byte of a MIDI message.
void setCommandByte(int byte);
Set the command byte (command nibble + channel nibble) of a MIDI message.
Set the command byte (command nibble + channel nibble) of a MIDI message.
Source code for setCommandByte on GitHub
////////////////////////////// // // MidiMessage::setCommandByte -- // void MidiMessage::setCommandByte(int value) { if (size() < 1) { resize(1); } else { (*this)[0] = (uchar)(value & 0xff); } } void MidiMessage::setCommand(int value) { setCommandByte(value); }
getCommandNibble — Return the command nibble of the MIDI message.
int getCommandNibble(void);
Return the top four bits of the command byte of the MIDI message. The bottom 4 bits for the channel are cleared. The return value is 0x80 to 0xf0.
Return the top four bits of the command byte of the MIDI message. The bottom 4 bits for the channel are cleared. The return value is 0x80 to 0xf0.
Source code for getCommandNibble on GitHub
////////////////////////////// // // MidiMessage::getCommandNibble -- Returns the top 4 bits of the (*this)[0] // entry, or -1 if there is not (*this)[0]. // int MidiMessage::getCommandNibble(void) { if (size() < 1) { return -1; } else { return (*this)[0] & 0xf0; } }
setCommandNibble — Set the command nibble of a command byte.
void setCommandNibble(int nibble);
Set the command nibble of a command byte. The value can either be in the range from 0x8 to 0xf, or 0x80 to 0xf0.
Set the command nibble of a command byte. The value can either be in the range from 0x8 to 0xf, or 0x80 to 0xf0.
Source code for setCommandNibble on GitHub
////////////////////////////// // // MidiMessage::setCommandNibble -- // void MidiMessage::setCommandNibble(int value) { if (this->size() < 1) { this->resize(1); } if (value <= 0x0f) { (*this)[0] = ((*this)[0] & 0x0f) | ((uchar)((value << 4) & 0xf0)); } else { (*this)[0] = ((*this)[0] & 0x0f) | ((uchar)(value & 0xf0)); } }
setParameters — Set the message bytes after the command byte.
void setParameters(int p1);
void setParameters(int p1, int p2);
Set the second and optionally the third MIDI bytes of a MIDI message. The command byte will not be altered, and will be set to 0 if it currently does not exist.
void setParameters(int p1, int p2);
Set the second and optionally the third MIDI bytes of a MIDI message. The command byte will not be altered, and will be set to 0 if it currently does not exist.
Source code for setParameters on GitHub
////////////////////////////// // // MidiMessage::setParameters -- Set the second and optionally the // third MIDI byte of a MIDI message. The command byte will not // be altered, and will be set to 0 if it currently does not exist. // void MidiMessage::setParameters(int p1) { int oldsize = (int)size(); resize(2); (*this)[1] = (uchar)p1; if (oldsize < 1) { (*this)[0] = 0; } } void MidiMessage::setParameters(int p1, int p2) { int oldsize = (int)size(); resize(3); (*this)[1] = (uchar)p1; (*this)[2] = (uchar)p2; if (oldsize < 1) { (*this)[0] = 0; } }
setSizeToCommand — Set the number of parameters given the stored command byte.
getSize — Returns the number of bytes in the MIDI message.
setSize — Change the size of the message byte list.
operatorEQUALS — Copy the contents of another MidiMessage.
isMeta — Returns true if MIDI message is a meta message.
setMetaTempo — Create a tempo meta message from a tempo.
isTempo — Returns true if MIDI message is a tempo meta message.
getTempoBPM — Return the tempo in terms of quarter notes per minute.
getTempoMicro — Return the number of microseconds per quarter note.
getTempoSPT — Return the tempo in terms of seconds per tick.
getTempoSeconds — Return the number of seconds per quarter note.
getTempoTPS — Return the tempo in terms of ticks per second.
Keyboard shortcuts for this page:
- ctrl++/= to open all function documentation entries.
- ctrl+– to close all documentation.
- ctrl+eto toggle display of all code examples.
- shft+click will open documentation for a single method and close all other entries.