Om
1.0.0
A universal framework for multimedia simulation
|
A class that represents a single MIDI message. More...
#include <omSoundMIDIMessage.h>
Public Types | |
enum | Type { NOTE_ON, NOTE_OFF, CONTROL_CHANGE, AFTERTOUCH, CHANNEL_PRESSURE, PITCH_WHEEL, PROGRAM_CHANGE, START, STOP, CONTINUE, UNDEFINED } |
An enum which indicates the type of a MIDI message. More... | |
Public Member Functions | |
MIDIMessage () | |
Create a default MIDI message with undefined type. More... | |
MIDIMessage (Type newType) | |
Create a MIDI message with the specified type with all other data members set to 0. More... | |
MIDIMessage (Type newType, Index newChannel, UByte newData1) | |
Create a MIDI message with the specified type, channel, and integral data member. More... | |
MIDIMessage (Type newType, Index newChannel, Float newData2) | |
Create a MIDI message with the specified type, channel, and floating point data member. More... | |
MIDIMessage (Type newType, Index newChannel, UByte newData1, Float newData2) | |
Create a MIDI message with the specified type, channel, integral data member, and floating point data member. More... | |
Type | getType () const |
Return the type of this MIDI message. More... | |
Index | getChannel () const |
Return the number of the channel associated with this MIDI message (if applicable). More... | |
UByte | getData1 () const |
Return the integer data element for this midi message. More... | |
Float | getData2 () const |
Return the floating-point data element for this midi message. More... | |
UByte | getNote () const |
Return the note number associated with this MIDI message. More... | |
Float | getVelocity () const |
Return the note velocity associated with this MIDI message. More... | |
UByte | getControl () const |
Return the control index associated with this MIDI message. More... | |
Float | getControlValue () const |
Return the control value associated with this MIDI message. More... | |
Float | getPressure () const |
Return the pressure value associated with this MIDI message. More... | |
Float | getPitch () const |
Return the pitch shift amount associated with this MIDI message. More... | |
UByte | getProgram () const |
Return the program index associated with this MIDI message. More... | |
Static Public Member Functions | |
static Bool | fromBytes (const UByte *bytes, MIDIMessage &message, Size &messageLengthInBytes) |
Parse a MIDI message object from a pointer to an array of bytes for the MIDI message. More... | |
static Bool | toBytes (const MIDIMessage &message, UByte *bytes, Size &messageLengthInBytes) |
Convert the specified MIDIMessage object to a sequence of MIDI data stream bytes. More... | |
A class that represents a single MIDI message.
This implementation does not support SysEx MIDI messages. All common MIDI message types are supported. The message contains a type, a channel index on which the message occurred, an integer data member, and a floating-point data member. The usage of the data members depends on the type of the MIDI message.
An enum which indicates the type of a MIDI message.
Enumerator | |
---|---|
NOTE_ON |
A message type indicating that a note was turned on. |
NOTE_OFF |
A message type indicating that a note was turned off. |
CONTROL_CHANGE |
A message type indicating that a control parameter was changed. |
AFTERTOUCH |
A message type indicating a change in a key's current pressure. |
CHANNEL_PRESSURE |
A message type indicating a change in a MIDI channel's global pressure. |
PITCH_WHEEL |
A message type indicating a change in the pitch wheel's position. |
PROGRAM_CHANGE |
A message type indicating that the current patch should be changed. |
START |
A message type indicating that a slave device should start playback from the start of a song. |
STOP |
A message type indicating that a slave device should stop playback. |
CONTINUE |
A message type indicating that a slave device should continue playback from its current position. |
UNDEFINED |
An undefined message type. |
|
inline |
Create a default MIDI message with undefined type.
|
inline |
Create a MIDI message with the specified type with all other data members set to 0.
Create a MIDI message with the specified type, channel, and integral data member.
Create a MIDI message with the specified type, channel, and floating point data member.
|
inline |
Create a MIDI message with the specified type, channel, integral data member, and floating point data member.
|
inline |
Return the number of the channel associated with this MIDI message (if applicable).
This value has no meaning if the message type is one with global effect, such as START, STOP, or CONTINUE.
|
inline |
Return the integer data element for this midi message.
The information carried in this first data member is dependent on the message type:
|
inline |
Return the floating-point data element for this midi message.
The information carried in this second data member is dependent on the message type:
|
inline |
Return the note number associated with this MIDI message.
The returned note number is valid only if the message type is NOTE_ON, NOTE_OFF, or AFTERTOUCH.
|
inline |
Return the note velocity associated with this MIDI message.
The returned note velocity is valid only if the message type is NOTE_ON or NOTE_OFF. The velocity is in the range [0,1], where 1 is the highest note velocity.
|
inline |
Return the control index associated with this MIDI message.
The returned control index is valid only if the message type is CONTROL_CHANGE.
|
inline |
Return the control value associated with this MIDI message.
The returned value is valid only if the message type is CONTROL_CHANGE. The value is unitless and in the range [0,1].
|
inline |
Return the pressure value associated with this MIDI message.
The returned pressure is valid only if the message type is AFTERTOUCH or CHANNEL_PRESSURE. The pressure is in the range [0,1].
|
inline |
Return the pitch shift amount associated with this MIDI message.
The returned value is valid only if the message type is PITCH_WHEEL. The pitch shift amount is unitless and in the range [-1,1]. Users should define a mapping from this range to semitones, etc.
|
inline |
Return the program index associated with this MIDI message.
The returned program index is valid only if the message type is PROGRAM_CHANGE.
|
static |
Parse a MIDI message object from a pointer to an array of bytes for the MIDI message.
If the method succeeds, TRUE is returned and the output message parameter is set to be the parsed MIDI message. The length of the message in bytes is placed in the message length parameter.
If the method fails, indicating a parse error, FALSE is returned.
|
static |
Convert the specified MIDIMessage object to a sequence of MIDI data stream bytes.
If the method succeeds, TRUE is returned and the message data is written to the byte array pointer. The length of the message in bytes is placed in the message length parameter.
The output byte array must be at least 3 bytes long, the length of a standard (non-sysex) MIDI message.
If the method fails, indicating a conversion error, FALSE is returned.