NiCMidi 1.1.0
A MIDI library derived from J.D.Koftinoff jdksmidi
MIDIMessage Class Reference

Stores data representing a MIDI event message. More...

#include <msg.h>

Inheritance diagram for MIDIMessage:
MIDITimedMessage

Public Member Functions

 MIDIMessage ()
 Creates a a NoOp MIDIMessage (an undefined MIDI message, which will be ignored when playing). More...
 
 MIDIMessage (const MIDIMessage &msg)
 The copy constructor. More...
 
virtual ~MIDIMessage ()
 The destructor. More...
 
virtual void Clear ()
 Resets the message and frees the MIDISystemExclusive pointer; the message becomes a NoOp. More...
 
void ClearSysEx ()
 Frees the MIDISystemExclusive pointer without changing other bytes. More...
 
const MIDIMessageoperator= (const MIDIMessage &msg)
 The assignment operator. More...
 
int GetLength () const
 Returns the length in bytes of the entire message. More...
 
unsigned char GetStatus () const
 Returns the status byte of the message. More...
 
unsigned char GetChannel () const
 If the message is a channel message, returns its MIDI channel. More...
 
unsigned char GetType () const
 Returns the relevant top 4 bits of the status byte, which describe what type of channel message it is. More...
 
unsigned char GetMetaType () const
 If the message is a meta-message, returns the type byte. See MIDI Enumerations for meta event types.. More...
 
unsigned char GetByte1 () const
 Returns the raw value of the data byte 1 of the message. More...
 
unsigned char GetByte2 () const
 Returns the raw value of the data byte 2 of the message. More...
 
unsigned char GetByte3 () const
 Returns the raw value of the data byte 3 of the message. More...
 
MIDISystemExclusiveGetSysEx ()
 Returns a pointer to the MIDISystemExclusive object (0 if it is not allocated). More...
 
const MIDISystemExclusiveGetSysEx () const
 Returns a pointer to the MIDISystemExclusive object (0 if it is not allocated). More...
 
unsigned char GetNote () const
 If the message is a note on, note off, or poly aftertouch message, returns the note number. More...
 
unsigned char GetVelocity () const
 If the message is a note on, note off, or poly aftertouch message, returns the note velocity (or pressure). More...
 
unsigned char GetChannelPressure () const
 If the message is a channel pressure message, returns the pressure value. More...
 
unsigned char GetProgramValue () const
 If the message is a program change (patch) message, returns the program number. More...
 
unsigned char GetController () const
 If the message is a control change message, returns the controller number. More...
 
unsigned char GetControllerValue () const
 If the message is a control change message, returns the controller value. More...
 
int16_t GetBenderValue () const
 If the message is a bender message, returns the signed 14 bit bender value. More...
 
uint16_t GetMetaValue () const
 If the message is a meta-message, returns the unsigned 14 bit value attached. More...
 
unsigned char GetTimeSigNumerator () const
 If the message is a time signature meta-message, returns the numerator of the time signature. More...
 
unsigned char GetTimeSigDenominator () const
 If the message is a time signature meta-message, returns the denominator of the time signature. More...
 
signed char GetKeySigSharpsFlats () const
 If the message is a key signature meta-message, returns the key in SMF format. More...
 
unsigned char GetKeySigMode () const
 If the message is a key signature meta-message, returns major/minor SMF flag. More...
 
float GetTempo () const
 If the message is a tempo change meta-message, returns the tempo value in bpm. More...
 
unsigned long GetInternalTempo () const
 If the message is a tempo change meta-message, returns the tempo in SMF format. More...
 
std::string GetText () const
 If the message is a text meta-message, returns the associated text as a std::string. More...
 
bool IsChannelMsg () const
 Returns true if the message is some sort of channel message. More...
 
bool IsNoteOn () const
 Returns true if the message is a note on message (status == NOTE_ON and velocity > 0). More...
 
bool IsNoteOff () const
 Returns true if the message is a note off message (status == NOTE_OFF or status == NOTE_ON and velocity == 0). More...
 
bool IsNote () const
 Returns true if the message is a note on or a note off message. More...
 
bool IsPolyPressure () const
 Returns true if the message is a polyphonic pressure channel message. More...
 
bool IsControlChange () const
 Returns true if the message is a control change message. More...
 
bool IsVolumeChange () const
 Returns true if the message is a volume change message (control == 0x07). More...
 
bool IsPanChange () const
 Returns true if the message is a pan change message (control == 0x0A). More...
 
bool IsPedalOn () const
 Returns true if the message is a pedal on message (control == 0x40 and value >= 0x64). More...
 
bool IsPedalOff () const
 Returns true if the message is a pedal off message (control == 0x40 and value < 0x64). More...
 
bool IsProgramChange () const
 Returns true if the message is a program change message. More...
 
bool IsChannelPressure () const
 Returns true if the message is a channel pressure message. More...
 
bool IsPitchBend () const
 Returns true if the message is a bender message. More...
 
bool IsChannelMode () const
 Returns true if the message is a channel mode message (a control change with control >= 0x7A). More...
 
bool IsAllNotesOff () const
 Returns true if the message is a all notes off message. More...
 
bool IsSystemMessage () const
 Returns true if the message is a system message (the status byte is 0xf0 or higher). More...
 
bool IsSysEx () const
 Returns true if the message is a system exclusive message. More...
 
bool IsMetaEvent () const
 Returns true if the message is a meta event message. More...
 
bool IsTextEvent () const
 Returns true if the message is a text message (a subset of meta events). More...
 
bool IsTrackName () const
 Returns true if the message is a track name meta-message. More...
 
bool IsMarkerText () const
 Returns true if the message is a marker text meta-message. More...
 
bool IsTempo () const
 Returns true if the message is a tempo change meta-message. More...
 
bool IsDataEnd () const
 Returns true if the message is a data end (i.e. end of track) meta-message. More...
 
bool IsSMPTEOffset () const
 Returns true if the message is a SMPTE offset meta-message. More...
 
bool IsTimeSig () const
 Returns true if the message is a time Signature meta-message. More...
 
bool IsKeySig () const
 Returns true if the message is a key signature meta-message. More...
 
bool IsNoOp () const
 Returns true if the message is a NoOp (not initialized) message. More...
 
bool IsBeatMarker () const
 Returns true if the message is a beat marker message. More...
 
void SetStatus (unsigned char s)
 Sets all 8 bits of the status byte of the message. These define, for channel messages, the type and the channel. More...
 
void SetChannel (unsigned char s)
 Sets the lower 4 bits of the status byte without changing the upper 4 bits. See Numbering conventions. More...
 
void SetType (unsigned char s)
 Sets the upper 4 bits of the status byte without changing the lower 4 bits. More...
 
void SetByte1 (unsigned char b)
 Sets the raw value of the data byte 1 of the message. More...
 
void SetByte2 (unsigned char b)
 Sets the raw value of the data byte 2 of the message. More...
 
void SetByte3 (unsigned char b)
 Sets the raw value of the data byte 3 of the message. More...
 
void SetNote (unsigned char n)
 Sets the note number for note on, note off, and polyphonic aftertouch messages. More...
 
void SetVelocity (unsigned char v)
 Sets the velocity for note on, note off and polyphonic aftertouch messages. More...
 
void SetController (unsigned char c)
 Sets the controller number for a control change message. More...
 
void SetControllerValue (unsigned char v)
 Sets the controller value for a control change message. More...
 
void SetProgramValue (unsigned char v)
 Sets the program number for a program change message. More...
 
void SetBenderValue (int16_t v)
 Sets the bender value (a signed 14 bit value) for a bender message. More...
 
void SetMetaType (unsigned char t)
 Sets the meta message type for a meta-event message. More...
 
void SetMetaValue (unsigned short v)
 Sets the meta value for a meta-event message. More...
 
void SetNoteOn (unsigned char chan, unsigned char note, unsigned char vel)
 Makes the message a note on message with given channel, note and velocity. More...
 
void SetNoteOff (unsigned char chan, unsigned char note, unsigned char vel)
 Makes the message a note off message with given channel, note and velocity. More...
 
void SetPolyPressure (unsigned char chan, unsigned char note, unsigned char pres)
 Makes the message a polyphonic aftertouch message with given channel, note and pressure. More...
 
void SetControlChange (unsigned char chan, unsigned char ctrl, unsigned char val)
 Makes the message a control change message with given channel, controller and value. More...
 
void SetVolumeChange (unsigned char chan, unsigned char val)
 Makes the message a volume change (control == 0x07) message with given channel and value. More...
 
void SetPanChange (unsigned char chan, unsigned char val)
 Makes the message a pan change (control == 0x0A) message with given channel and value. More...
 
void SetProgramChange (unsigned char chan, unsigned char prog)
 Makes the message a program change message with given channel and program. More...
 
void SetChannelPressure (unsigned char chan, unsigned char pres)
 Makes the message a channel pressure message with given channel and pressure. More...
 
void SetPitchBend (unsigned char chan, short val)
 Makes the message a pitch bend message with given channel and value (unsigned 14 bit). More...
 
void SetChannelMode (unsigned char chan, unsigned char type, unsigned char val=0)
 Makes the message a channel mode message (i.e. More...
 
void SetAllNotesOff (unsigned char chan)
 Makes the message a all notes off message with given channel. More...
 
void SetSysEx (const MIDISystemExclusive *se)
 Makes the message a system exclusive message with given MIDISystemExclusive object. More...
 
void SetMTC (unsigned char field, unsigned char val)
 Makes the message a MIDI time code message with given field (3 bits) and value (4 bits). Frees the sysex pointer. More...
 
void SetSongPosition (int16_t pos)
 Makes the message a song position system message with given position (14 bits). Frees the sysex pointer. More...
 
void SetSongSelect (unsigned char sng)
 Makes the message a song select system message with given song. Frees the sysex pointer. More...
 
void SetSystemMessage (unsigned char type)
 Makes the message a one-byte system message with given status (type must be a valid MIDI system message status byte, see MIDI Enumerations). More...
 
void SetMetaEvent (unsigned char type, unsigned char v1, unsigned char v2)
 Makes the message a meta-message with given type and data value. More...
 
void SetMetaEvent (unsigned char type, unsigned short val)
 Makes the message a meta-message with given type and data value. More...
 
void SetText (const char *text, unsigned char type=META_GENERIC_TEXT)
 Makes the message a text meta-message with given type. More...
 
void SetDataEnd ()
 Makes the message a data end (i.e. end of track) meta-message. More...
 
void SetTempo (float tempo_bpm)
 Makes the message a tempo change meta-message with given tempo (in bpm). More...
 
void SetSMPTEOffset (unsigned char hour, unsigned char min, unsigned char sec, unsigned char frame, unsigned char subframe)
 Makes the message a SMPTE offset meta-message with given data. More...
 
void SetTimeSig (unsigned char num, unsigned char den, unsigned char clocks_per_metronome=0, unsigned char num_32_per_quarter=8)
 Makes the message a time signature meta-message with given time (numerator and denominator). More...
 
void SetKeySig (signed char sharp_flats, unsigned char major_minor)
 Makes the message a key signature meta-message with given accidents and mode. More...
 
void SetNoOp ()
 The same of Clear(), makes the message an uninitialized message which will be ignored. More...
 
void SetBeatMarker ()
 Makes the message a beat marker internal service message. More...
 
virtual std::string MsgToText (bool chan_from_1=false) const
 Returns a human readable ascii string describing the message content. More...
 
void AllocateSysEx (unsigned int len)
 Allocates a MIDISystemExclusive object, with a buffer of given max size. More...
 
void CopySysEx (const MIDISystemExclusive *se)
 Copies the given MIDISystemExclusive object into the message without changing other bytes. More...
 

Static Public Member Functions

static void UseNoteOnv0ForOff (bool f)
 This static method determines if the SetNoteOff() method will produce a MIDI NOTE_OFF message or a NOTE_ON with velocity 0. More...
 

Friends

bool operator== (const MIDIMessage &m1, const MIDIMessage &m2)
 The compare operator executes a bitwise comparison. More...
 

Detailed Description

Stores data representing a MIDI event message.

It consists of a status byte, three data bytes for subsequent data and a pointer to a MIDISystemExclusive object that can store larger amounts of data. Ordinary channel messages only use the data bytes, while some meta messages and sysex messages also use the pointer. Lots of methods are provided for setting and inspecting the message data without worrying about hexadecimal values. See the file midi.h for a set of enum values for MIDI messages data. In addition to MIDI messages, the MIDIMessage can also contain two types of internal service messages: the NoOp (a null, not initialized message) and the beat marker, used by the MIDISequencer as metronome click.

Constructor & Destructor Documentation

◆ MIDIMessage() [1/2]

MIDIMessage::MIDIMessage ( )

Creates a a NoOp MIDIMessage (an undefined MIDI message, which will be ignored when playing).

◆ MIDIMessage() [2/2]

MIDIMessage::MIDIMessage ( const MIDIMessage msg)

The copy constructor.

If the target message has a MIDISystemExclusive object it is duplicated, so every MIDIMessage has its own object.

◆ ~MIDIMessage()

virtual MIDIMessage::~MIDIMessage ( )
virtual

The destructor.

Member Function Documentation

◆ Clear()

virtual void MIDIMessage::Clear ( )
virtual

Resets the message and frees the MIDISystemExclusive pointer; the message becomes a NoOp.

Reimplemented in MIDITimedMessage.

◆ ClearSysEx()

void MIDIMessage::ClearSysEx ( )

Frees the MIDISystemExclusive pointer without changing other bytes.

◆ operator=()

const MIDIMessage & MIDIMessage::operator= ( const MIDIMessage msg)

The assignment operator.

It primarily frees the old MIDISystemExclusive object if it was allocated, then duplicates the (eventual) new MIDISystemExclusive, so every MIDIMessage has its own object.

◆ GetLength()

int MIDIMessage::GetLength ( ) const

Returns the length in bytes of the entire message.

It can return -1 for messages whose length is unknown (for example sysex).

◆ GetStatus()

unsigned char MIDIMessage::GetStatus ( ) const
inline

Returns the status byte of the message.

If the message is a channel message this contains the message type in the top 4 bits and the channel in the bottom 4, for other messages this is the same of GetType(). See MIDI Enumerations for status bytes.

◆ GetChannel()

unsigned char MIDIMessage::GetChannel ( ) const
inline

If the message is a channel message, returns its MIDI channel.

See Numbering conventions.

◆ GetType()

unsigned char MIDIMessage::GetType ( ) const
inline

Returns the relevant top 4 bits of the status byte, which describe what type of channel message it is.

See MIDI Enumerations for status bytes.

◆ GetMetaType()

unsigned char MIDIMessage::GetMetaType ( ) const
inline

If the message is a meta-message, returns the type byte. See MIDI Enumerations for meta event types..

◆ GetByte1()

unsigned char MIDIMessage::GetByte1 ( ) const
inline

Returns the raw value of the data byte 1 of the message.

◆ GetByte2()

unsigned char MIDIMessage::GetByte2 ( ) const
inline

Returns the raw value of the data byte 2 of the message.

◆ GetByte3()

unsigned char MIDIMessage::GetByte3 ( ) const
inline

Returns the raw value of the data byte 3 of the message.

◆ GetSysEx() [1/2]

MIDISystemExclusive * MIDIMessage::GetSysEx ( )
inline

Returns a pointer to the MIDISystemExclusive object (0 if it is not allocated).

◆ GetSysEx() [2/2]

const MIDISystemExclusive * MIDIMessage::GetSysEx ( ) const
inline

Returns a pointer to the MIDISystemExclusive object (0 if it is not allocated).

◆ GetNote()

unsigned char MIDIMessage::GetNote ( ) const
inline

If the message is a note on, note off, or poly aftertouch message, returns the note number.

◆ GetVelocity()

unsigned char MIDIMessage::GetVelocity ( ) const
inline

If the message is a note on, note off, or poly aftertouch message, returns the note velocity (or pressure).

◆ GetChannelPressure()

unsigned char MIDIMessage::GetChannelPressure ( ) const
inline

If the message is a channel pressure message, returns the pressure value.

◆ GetProgramValue()

unsigned char MIDIMessage::GetProgramValue ( ) const
inline

If the message is a program change (patch) message, returns the program number.

◆ GetController()

unsigned char MIDIMessage::GetController ( ) const
inline

If the message is a control change message, returns the controller number.

◆ GetControllerValue()

unsigned char MIDIMessage::GetControllerValue ( ) const
inline

If the message is a control change message, returns the controller value.

◆ GetBenderValue()

int16_t MIDIMessage::GetBenderValue ( ) const
inline

If the message is a bender message, returns the signed 14 bit bender value.

◆ GetMetaValue()

uint16_t MIDIMessage::GetMetaValue ( ) const
inline

If the message is a meta-message, returns the unsigned 14 bit value attached.

◆ GetTimeSigNumerator()

unsigned char MIDIMessage::GetTimeSigNumerator ( ) const
inline

If the message is a time signature meta-message, returns the numerator of the time signature.

◆ GetTimeSigDenominator()

unsigned char MIDIMessage::GetTimeSigDenominator ( ) const
inline

If the message is a time signature meta-message, returns the denominator of the time signature.

◆ GetKeySigSharpsFlats()

signed char MIDIMessage::GetKeySigSharpsFlats ( ) const
inline

If the message is a key signature meta-message, returns the key in SMF format.

Negative values mean that many flats, positive values mean that many sharps.

◆ GetKeySigMode()

unsigned char MIDIMessage::GetKeySigMode ( ) const
inline

If the message is a key signature meta-message, returns major/minor SMF flag.

0 means a major key, 1 means a minor key.

◆ GetTempo()

float MIDIMessage::GetTempo ( ) const

If the message is a tempo change meta-message, returns the tempo value in bpm.

◆ GetInternalTempo()

unsigned long MIDIMessage::GetInternalTempo ( ) const

If the message is a tempo change meta-message, returns the tempo in SMF format.

This is a 3 bytes value (the number of microseconds per quarter note).

◆ GetText()

std::string MIDIMessage::GetText ( ) const

If the message is a text meta-message, returns the associated text as a std::string.

◆ IsChannelMsg()

bool MIDIMessage::IsChannelMsg ( ) const
inline

Returns true if the message is some sort of channel message.

You can then call GetChannel() and GetType() for further information.

◆ IsNoteOn()

bool MIDIMessage::IsNoteOn ( ) const
inline

Returns true if the message is a note on message (status == NOTE_ON and velocity > 0).

You can then call GetChannel(), GetNote() and GetVelocity() for further information.

◆ IsNoteOff()

bool MIDIMessage::IsNoteOff ( ) const
inline

Returns true if the message is a note off message (status == NOTE_OFF or status == NOTE_ON and velocity == 0).

You can then call GetChannel() and GetNote() for further information.

◆ IsNote()

bool MIDIMessage::IsNote ( ) const
inline

Returns true if the message is a note on or a note off message.

◆ IsPolyPressure()

bool MIDIMessage::IsPolyPressure ( ) const
inline

Returns true if the message is a polyphonic pressure channel message.

You can then call GetChannel(), GetNote() and GetVelocity() for further information.

◆ IsControlChange()

bool MIDIMessage::IsControlChange ( ) const
inline

Returns true if the message is a control change message.

You can then call GetChannel(), GetController() and GetControllerValue() for further information.

Note
This will return false on channel mode messages (which have the same status byte of control changes). Call IsChannelMode() for inspecting them.

◆ IsVolumeChange()

bool MIDIMessage::IsVolumeChange ( ) const
inline

Returns true if the message is a volume change message (control == 0x07).

You can then call GetChannel() and GetControllerValue() for further information.

◆ IsPanChange()

bool MIDIMessage::IsPanChange ( ) const
inline

Returns true if the message is a pan change message (control == 0x0A).

You can then call GetChannel() and GetControllerValue() for further information.

◆ IsPedalOn()

bool MIDIMessage::IsPedalOn ( ) const
inline

Returns true if the message is a pedal on message (control == 0x40 and value >= 0x64).

You can then call GetChannel() for further information.

◆ IsPedalOff()

bool MIDIMessage::IsPedalOff ( ) const
inline

Returns true if the message is a pedal off message (control == 0x40 and value < 0x64).

You can then call GetChannel() for further information.

◆ IsProgramChange()

bool MIDIMessage::IsProgramChange ( ) const
inline

Returns true if the message is a program change message.

You can then call GetChannel() and GetProgramValue() for further information.

◆ IsChannelPressure()

bool MIDIMessage::IsChannelPressure ( ) const
inline

Returns true if the message is a channel pressure message.

You can then call GetChannel() and GetChannelPressure() for further information.

◆ IsPitchBend()

bool MIDIMessage::IsPitchBend ( ) const
inline

Returns true if the message is a bender message.

You can then call GetChannel() and GetBenderValue() for further information.

◆ IsChannelMode()

bool MIDIMessage::IsChannelMode ( ) const
inline

Returns true if the message is a channel mode message (a control change with control >= 0x7A).

◆ IsAllNotesOff()

bool MIDIMessage::IsAllNotesOff ( ) const
inline

Returns true if the message is a all notes off message.

◆ IsSystemMessage()

bool MIDIMessage::IsSystemMessage ( ) const
inline

Returns true if the message is a system message (the status byte is 0xf0 or higher).

◆ IsSysEx()

bool MIDIMessage::IsSysEx ( ) const
inline

Returns true if the message is a system exclusive message.

◆ IsMetaEvent()

bool MIDIMessage::IsMetaEvent ( ) const
inline

Returns true if the message is a meta event message.

You can then call GetMetaType() and GetMetaValue() for further information.

◆ IsTextEvent()

bool MIDIMessage::IsTextEvent ( ) const
inline

Returns true if the message is a text message (a subset of meta events).

You can then call GetText() for further information.

◆ IsTrackName()

bool MIDIMessage::IsTrackName ( ) const
inline

Returns true if the message is a track name meta-message.

You can then call GetText() for further information.

◆ IsMarkerText()

bool MIDIMessage::IsMarkerText ( ) const
inline

Returns true if the message is a marker text meta-message.

You can then call GetText() for further information.

◆ IsTempo()

bool MIDIMessage::IsTempo ( ) const
inline

Returns true if the message is a tempo change meta-message.

You can then call GetTempo() or GetInternalTempo() for further information.

◆ IsDataEnd()

bool MIDIMessage::IsDataEnd ( ) const
inline

Returns true if the message is a data end (i.e. end of track) meta-message.

◆ IsSMPTEOffset()

bool MIDIMessage::IsSMPTEOffset ( ) const
inline

Returns true if the message is a SMPTE offset meta-message.

The SMPTE data are kept in the MIDISystemExclusive object.

◆ IsTimeSig()

bool MIDIMessage::IsTimeSig ( ) const
inline

Returns true if the message is a time Signature meta-message.

You can then call GetTimeSigNumerator() and GetTimeSigDenominator() for further information.

◆ IsKeySig()

bool MIDIMessage::IsKeySig ( ) const
inline

Returns true if the message is a key signature meta-message.

You can then call GetKeySigSharpsFlats() and GetKeySigMode() for further information.

◆ IsNoOp()

bool MIDIMessage::IsNoOp ( ) const
inline

Returns true if the message is a NoOp (not initialized) message.

◆ IsBeatMarker()

bool MIDIMessage::IsBeatMarker ( ) const
inline

Returns true if the message is a beat marker message.

This is an internal service message used by the MIDISequencer class to mark the metronome clicks.

◆ SetStatus()

void MIDIMessage::SetStatus ( unsigned char  s)
inline

Sets all 8 bits of the status byte of the message. These define, for channel messages, the type and the channel.

◆ SetChannel()

void MIDIMessage::SetChannel ( unsigned char  s)
inline

Sets the lower 4 bits of the status byte without changing the upper 4 bits. See Numbering conventions.

◆ SetType()

void MIDIMessage::SetType ( unsigned char  s)
inline

Sets the upper 4 bits of the status byte without changing the lower 4 bits.

◆ SetByte1()

void MIDIMessage::SetByte1 ( unsigned char  b)
inline

Sets the raw value of the data byte 1 of the message.

◆ SetByte2()

void MIDIMessage::SetByte2 ( unsigned char  b)
inline

Sets the raw value of the data byte 2 of the message.

◆ SetByte3()

void MIDIMessage::SetByte3 ( unsigned char  b)
inline

Sets the raw value of the data byte 3 of the message.

◆ SetNote()

void MIDIMessage::SetNote ( unsigned char  n)
inline

Sets the note number for note on, note off, and polyphonic aftertouch messages.

◆ SetVelocity()

void MIDIMessage::SetVelocity ( unsigned char  v)
inline

Sets the velocity for note on, note off and polyphonic aftertouch messages.

◆ SetController()

void MIDIMessage::SetController ( unsigned char  c)
inline

Sets the controller number for a control change message.

◆ SetControllerValue()

void MIDIMessage::SetControllerValue ( unsigned char  v)
inline

Sets the controller value for a control change message.

◆ SetProgramValue()

void MIDIMessage::SetProgramValue ( unsigned char  v)
inline

Sets the program number for a program change message.

◆ SetBenderValue()

void MIDIMessage::SetBenderValue ( int16_t  v)

Sets the bender value (a signed 14 bit value) for a bender message.

◆ SetMetaType()

void MIDIMessage::SetMetaType ( unsigned char  t)
inline

Sets the meta message type for a meta-event message.

◆ SetMetaValue()

void MIDIMessage::SetMetaValue ( unsigned short  v)

Sets the meta value for a meta-event message.

◆ SetNoteOn()

void MIDIMessage::SetNoteOn ( unsigned char  chan,
unsigned char  note,
unsigned char  vel 
)

Makes the message a note on message with given channel, note and velocity.

Frees the sysex pointer.

Parameters
chan,note,velsee Numbering conventions
Examples
test_advancedsequencer_noinput.cpp, test_component.cpp, test_stepsequencer.cpp, and test_writefile.cpp.

◆ SetNoteOff()

void MIDIMessage::SetNoteOff ( unsigned char  chan,
unsigned char  note,
unsigned char  vel 
)

Makes the message a note off message with given channel, note and velocity.

Frees the sysex pointer. The default behavior of this method is to put a NOTE OFF type message and copy the given velocity; you can also make the method put a NOTE ON with 0 velocity (ignoring the third parameter). See the UseNoteOnv0ForOff() static method.

Parameters
chan,note,velsee Numbering conventions
Examples
test_component.cpp.

◆ SetPolyPressure()

void MIDIMessage::SetPolyPressure ( unsigned char  chan,
unsigned char  note,
unsigned char  pres 
)

Makes the message a polyphonic aftertouch message with given channel, note and pressure.

Frees the sysex pointer.

Parameters
chan,note,pressee Numbering conventions

◆ SetControlChange()

void MIDIMessage::SetControlChange ( unsigned char  chan,
unsigned char  ctrl,
unsigned char  val 
)

Makes the message a control change message with given channel, controller and value.

Frees the sysex pointer.

Parameters
chan,ctrl,valsee Numbering conventions
Examples
test_stepsequencer.cpp.

◆ SetVolumeChange()

void MIDIMessage::SetVolumeChange ( unsigned char  chan,
unsigned char  val 
)
inline

Makes the message a volume change (control == 0x07) message with given channel and value.

Frees the sysex pointer.

Parameters
chan,valsee Numbering conventions
Examples
test_advancedsequencer_noinput.cpp, test_recorder.cpp, and test_writefile.cpp.

◆ SetPanChange()

void MIDIMessage::SetPanChange ( unsigned char  chan,
unsigned char  val 
)
inline

Makes the message a pan change (control == 0x0A) message with given channel and value.

Frees the sysex pointer.

Parameters
chan,valsee Numbering conventions

◆ SetProgramChange()

void MIDIMessage::SetProgramChange ( unsigned char  chan,
unsigned char  prog 
)

Makes the message a program change message with given channel and program.

Frees the sysex pointer.

Parameters
chan,progsee Numbering conventions
Examples
test_advancedsequencer_noinput.cpp, test_recorder.cpp, test_stepsequencer.cpp, test_thru.cpp, and test_writefile.cpp.

◆ SetChannelPressure()

void MIDIMessage::SetChannelPressure ( unsigned char  chan,
unsigned char  pres 
)

Makes the message a channel pressure message with given channel and pressure.

Frees the sysex pointer.

Parameters
chan,pressee Numbering conventions

◆ SetPitchBend()

void MIDIMessage::SetPitchBend ( unsigned char  chan,
short  val 
)

Makes the message a pitch bend message with given channel and value (unsigned 14 bit).

Frees the sysex pointer.

Parameters
chan,valsee Numbering conventions

◆ SetChannelMode()

void MIDIMessage::SetChannelMode ( unsigned char  chan,
unsigned char  type,
unsigned char  val = 0 
)
inline

Makes the message a channel mode message (i.e.

a control change with a specific control number. Channel mode messages include:

  • All sound off (type = C_ALL_SOUND_OFF)
  • Reset all controllers (type = C_RESET)
  • Local control (type = C_LOCAL, value = 0x7f/0 for on/off)
  • All notes off (type = C_ALL_NOTES_OFF, see SetAllNotesOff())
  • Omni mode off (type = C_OMNI_OFF)
  • Omni mode on (type = C_OMNI_ON)
  • Mono mode on (type = C_MONO, value = number of channels to respond, 0 for all channels)
  • Poly mode on (type = C_POLY)
    Parameters
    chan,type,valsee Numbering conventions

◆ SetAllNotesOff()

void MIDIMessage::SetAllNotesOff ( unsigned char  chan)
inline

Makes the message a all notes off message with given channel.

Parameters
chansee Numbering conventions

◆ SetSysEx()

void MIDIMessage::SetSysEx ( const MIDISystemExclusive se)

Makes the message a system exclusive message with given MIDISystemExclusive object.

The eventual old sysex is freed and the MIDISystemExclusive is copied, so the message owns its object.

◆ SetMTC()

void MIDIMessage::SetMTC ( unsigned char  field,
unsigned char  val 
)

Makes the message a MIDI time code message with given field (3 bits) and value (4 bits). Frees the sysex pointer.

◆ SetSongPosition()

void MIDIMessage::SetSongPosition ( int16_t  pos)

Makes the message a song position system message with given position (14 bits). Frees the sysex pointer.

◆ SetSongSelect()

void MIDIMessage::SetSongSelect ( unsigned char  sng)

Makes the message a song select system message with given song. Frees the sysex pointer.

◆ SetSystemMessage()

void MIDIMessage::SetSystemMessage ( unsigned char  type)

Makes the message a one-byte system message with given status (type must be a valid MIDI system message status byte, see MIDI Enumerations).

Sets other bytes to 0 and frees the sysex pointer. This is useful mainly for messages which haven't data bytes, for others there are more appropriate methods.

◆ SetMetaEvent() [1/2]

void MIDIMessage::SetMetaEvent ( unsigned char  type,
unsigned char  v1,
unsigned char  v2 
)

Makes the message a meta-message with given type and data value.

The two bytes of data are given separately. See MIDI Enumerations for meta event types.

◆ SetMetaEvent() [2/2]

void MIDIMessage::SetMetaEvent ( unsigned char  type,
unsigned short  val 
)

Makes the message a meta-message with given type and data value.

You can use this for Sequence number (16 bit value) and Channel Prefix (8 bit value) messages.

◆ SetText()

void MIDIMessage::SetText ( const char *  text,
unsigned char  type = META_GENERIC_TEXT 
)

Makes the message a text meta-message with given type.

text is a C string containing the ascii characters and is stored in the sysex object (the eventual old pointer is freed). You can use this for Generic text, Copyright, Track name, Instrument name, Lyric, Marker and Cue point messages (see MIDI Enumerations for meta text types).

◆ SetDataEnd()

void MIDIMessage::SetDataEnd ( )
inline

Makes the message a data end (i.e. end of track) meta-message.

◆ SetTempo()

void MIDIMessage::SetTempo ( float  tempo_bpm)

Makes the message a tempo change meta-message with given tempo (in bpm).

The tempo is stored in the sysex object as a 3 byte value according to the SMF format and the eventual old pointer is freed.

Examples
test_advancedsequencer_noinput.cpp, test_stepsequencer.cpp, and test_writefile.cpp.

◆ SetSMPTEOffset()

void MIDIMessage::SetSMPTEOffset ( unsigned char  hour,
unsigned char  min,
unsigned char  sec,
unsigned char  frame,
unsigned char  subframe 
)

Makes the message a SMPTE offset meta-message with given data.

The bytes are stored in the sysex object and the eventual old pointer is freed.

◆ SetTimeSig()

void MIDIMessage::SetTimeSig ( unsigned char  num,
unsigned char  den,
unsigned char  clocks_per_metronome = 0,
unsigned char  num_32_per_quarter = 8 
)

Makes the message a time signature meta-message with given time (numerator and denominator).

The bytes are stored in the sysex object and the eventual old pointer is freed.

Examples
test_advancedsequencer_noinput.cpp, test_stepsequencer.cpp, and test_writefile.cpp.

◆ SetKeySig()

void MIDIMessage::SetKeySig ( signed char  sharp_flats,
unsigned char  major_minor 
)
inline

Makes the message a key signature meta-message with given accidents and mode.

Parameters
sharp_flats,major_minorThese are in SMF format: see GetKeySigSharpsFlats() and GetKeySigMode().
Examples
test_advancedsequencer_noinput.cpp, and test_writefile.cpp.

◆ SetNoOp()

void MIDIMessage::SetNoOp ( )
inline

The same of Clear(), makes the message an uninitialized message which will be ignored.

◆ SetBeatMarker()

void MIDIMessage::SetBeatMarker ( )

Makes the message a beat marker internal service message.

◆ MsgToText()

virtual std::string MIDIMessage::MsgToText ( bool  chan_from_1 = false) const
virtual

Returns a human readable ascii string describing the message content.

Parameters
chan_from_1if false channels are numbered 0 ... 15, otherwise 1 ... 16. See Numbering conventions

◆ AllocateSysEx()

void MIDIMessage::AllocateSysEx ( unsigned int  len)

Allocates a MIDISystemExclusive object, with a buffer of given max size.

The buffer is initially empty and can be accessed with GetSysEx(). An eventual old object is freed.

◆ CopySysEx()

void MIDIMessage::CopySysEx ( const MIDISystemExclusive se)

Copies the given MIDISystemExclusive object into the message without changing other bytes.

An eventual old object is freed.

◆ UseNoteOnv0ForOff()

static void MIDIMessage::UseNoteOnv0ForOff ( bool  f)
inlinestatic

This static method determines if the SetNoteOff() method will produce a MIDI NOTE_OFF message or a NOTE_ON with velocity 0.

The default is false (NOTE_OFF messages). If you want to use the other form call this with true.

Friends And Related Function Documentation

◆ operator==

bool operator== ( const MIDIMessage m1,
const MIDIMessage m2 
)
friend

The compare operator executes a bitwise comparison.


The documentation for this class was generated from the following file: