node
member.
For clarity, the members and methods of
MidiMsg are repeated here.
class MIDI_msg : public MidiMsg { public: enum // inherited from MidiMsg { note_off = 0, note_on = 1, poly_press = 2, control_chn = 3, program_chn = 4, chan_press = 5, pitch_bend = 6, system = 7 }; long time; // inherited from MidiMsg uchar s, d1, d2; // inherited from MidiMsg ext_dataPtr ed; // inherited from MidiMsg ioref node; static int msgt( uchar sb ); // inherited from MidiMsg static int smsgt( uchar sb ); // inherited from MidiMsg static int note_num(const char* name); // inherited from MidiMsg MIDI_msg(); MIDI_msg(const MIDI_msg& m); int msgt() const; // inherited from MidiMsg int smsgt() const; // inherited from MidiMsg int chan() const; // inherited from MidiMsg int dat14() const; // inherited from MidiMsg int bend() const; // inherited from MidiMsg int key() const; // inherited from MidiMsg int vel() const; // inherited from MidiMsg int len() const; // inherited from MidiMsg bool is_note_end() const; // inherited from MidiMsg bool is_ext() const; // inherited from MidiMsg void set_bend( float v ); // inherited from MidiMsg void set_stat_byt( int msgt, int lsn ); // inherited from MidiMsg void set_data14( int v ); // inherited from MidiMsg void set_chan(int c); // inherited from MidiMsg void set_key(int k); // inherited from MidiMsg void set_key(const char* k); // inherited from MidiMsg void set_vel(int v); // inherited from MidiMsg void set_sys_ex( uchar *r, long len ); // inherited from MidiMsg void set_meta( int meta_type, uchar *r, long len ); // inherited from MidiMsg void sprint( char *s ) const; // inherited from MidiMsg UtilStringPtr unparse() const; // inherited from MidiMsg bool is_on_for( const MIDI_msg& m ) const; void set( int msgt, int lsn, int dat1, int dat2, ioref node ); bool operator==(const MIDI_msg& m) const; MIDI_msg& operator=(const MIDI_msg& m); };
long time
uchar s, d1, d2
ext_dataPtr ed
ed
.
ioref node
static int msgt( uchar sb )
msgt(sb)
returns the basic MIDI message type as stored in the
high nibble of sb
. The basic MIDI message types appear as
enumerated constants within MidiMsg
.
static int smsgt( uchar sb )
smsgt(sb)
returns the system message type as stored in the low nibble of
sb
. The MIDI system message types appear as enumerated
constants in the smsgt
class. Note that smsgt()
is
only applicable to system messages (i.e. those for which
msgt(sb)==system
).
static int note_num(const char* name)
#
, flats
b
, double sharps ##
, and double flats
bb
are all supported. note_num()
returns the
MIDI note number if successful, or -1 if its argument cannot be parsed
as a valid note name.
MIDI_msg()
MIDI_msg(const MIDI_msg& m)
m
. Note that if m is an extended message, the
ed
member of the new MIDI_msg points to the same
ext_data as the ed
member of
m
, so a change to the contents of one's extended data
will affect the other.
int msgt() const
msgt()
returns the basic MIDI message type as stored in the
high nibble of the status byte. The basic MIDI message types appear as
enumerated constants within MidiMsg
.
int smsgt() const
smsgt()
returns the system message type as stored in the low nibble of the
status byte. The MIDI system message types appear as enumerated
constants in the smsgt
class. Note that smsgt()
is
only applicable to system messages (i.e. those for which
msgt()==system
).
int chan() const
chan()
returns the channel as
stored in the low nibble of the status byte. Note that this function
is only applicable to channel messages (i.e. those for which
msgt()!=system
).
int dat14() const
dat14()
returns the interpretation
of the data bytes as an unsigned14-bit integer.
int bend() const
bend()
returns the interpretation of the data bytes as a signed 14-bit
integer.
int key() const
key()
returns the key number (applicable to note on
or note off messages only).
int vel() const
vel()
returns the velocity (applicable to note on or note off messages only).
int len() const
len()
returns the length of the entire MIDI message.
bool is_note_end() const
is_note_end()
tells whether theMidiMsg
is a note
end. But what, you may ask, is a note end? Here I seek to introduce
an unambiguous vocabulary to deal with the somewhat confusing issue of
the representation of notes in MIDI. There are two ways to end a
note in MIDI: a note off message with any release velocity or a note on
message with a velocity of zero. I introduce the term "note end" to
refer to either of these types of messages.
bool is_ext() const
is_ext()
tells whether the message
contains extended data, i.e. whether theext_data
pointer
ed
is non-NULL.
void set_bend( float v )
set_bend()
sets the object's data bytes as if they were for a
pitch bend, but allows the amount of bend to be specified as a float in
[-1.0 ...1.0] which may be more convenient than as an integer. This
function will never produce the maximum negative pitch bend, 0x0000
(interpreted as -8192) since it scales symmetrically about zero and
the maximum positive pitch bend is only 0xF7F7 (interpreted as 8191).
Note that this function only manipulates the two data bytes, i.e. if
the status byte doesn't already indicate a pitch bend it needs to be
separately set to do so.
void set_stat_byt( int msgt, int lsn )
set_stat_byt()
sets the object's status byte to contain
message typemsgt
and least significant nibble lsn
.
For channel messages,the least significant nibble is the channel and
for system messages, it is the system message type.
void set_data14( int v )
set_data14()
sets the object's data bytes to
contain the 14-bit unsigned integer passed to it.
void set_chan(int c)
set_chan()
sets the least significant nibble of the
MidiMsg's status byte to c.
void set_key(int k)
set_key()
sets the first data byte of the MidiMsg to k.
void set_key(const char* k)
set_key
sets the first data byte of
the MIDI_msg to the MIDI note number of the note named k
.
The translation is performed using note_num()
, and if
k
is an invalid note name then the note is set to middle C.
void set_vel(int v)
set_vel()
sets the second data byte of the MidiMsg to v.
void set_sys_ex( uchar *r, long len )
set_sys_ex()
is used to set the extended data in a
MidiMsg
. r
is a pointer to the raw data and
len
is the length of this data. Implementation Note: extended
data is implemented by stealing an undefined system message type (see
smsgt::ext
) to flag that an extended message is pointed to by
ed
.
void set_meta( int meta_type, uchar *r, long len )
set_meta()
is used to set the extended data in a
MidiMsg
. r
is a pointer to the raw data,
len
is the length of this data, and
meta_type
is the type of metamessage. Meta message types are
enumerated in the class meta
. Implementation Note: extended
data is implemented by stealing an undefined system message type (see
smsgt::ext
) to flag that an extended message is pointed to by
ed
.
void sprint( char *s ) const
sprint()
puts a textual representation of the
MidiMsg
into the string pointed to by s
.
UtilStringPtr unparse() const
sprint()
has the disadvantage that you
don't know how long of a buffer you will need to store the string,
unparse()
is provided to eliminate this problem. It
returns the same string as sprint
, but returns it as a
UtilPtr to a UtilString.
bool is_on_for( const MIDI_msg& m ) const
is_on_for()
tells whether the object and its argument form a note on/end pair.
The object itself is assumed to be a note on.
void set( int msgt, int lsn, int dat1, int dat2, ioref node )
set()
sets the object's status byte as inset_stat_byt()
, sets the
data bytes to dat1
and dat2
respectively, and sets
the OMS node to node
. This method sets all of the data
necessary to send a non-sysex message out, so it is useful for creating
a MIDI_msg
from scratch.
bool operator==(const MIDI_msg& m) const
MIDI_msg& operator=(const MIDI_msg& m)