MIDI_msg


A MIDI_msg is a subclass of MidiMsg. It provides everything that MidiMsg does, with the addition of a 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
Inherited from MidiMsg. This member is used to store various time information. The filereader stores the time here in units of ticks, the ScorePlayer stores the time here in units of ScoreTime, and parsers receieve MIDI messages stamped with time in units of ScheduleTime.
uchar s, d1, d2
Inherited from MidiMsg. These three bytes represent the three bytes that actually make up the MIDI message when it is sent over the MIDI protocol.
ext_dataPtr ed
Inherited from MidiMsg. Additional data for System Exclusive and Meta messages is stored in ed.
ioref node
Indicates which node this MIDI_msg came from or should be sent to.
static int msgt( uchar sb )
Inherited from MidiMsg. 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 )
Inherited from MidiMsg. 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)
Inherited from MidiMsg. This function interprets its argument as the name of a note. For example, "C4" is middle C (MIDI note 60), "B3" is the note below middle C (MIDI note 59), "C#4" is a half-step above middle C (MIDI note 61), and "C5" is the note an octave above middle C (MIDI note 72). Sharps #, 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()
This constructor creates a MIDI_msg. All members are initialized to zero. Note that this means that the inital value of a MIDI_msg is not a valid MIDI message, since a valid MIDI message must have the high bit of the status byte set.
MIDI_msg(const MIDI_msg& m)
This constructor creates a new MIDI_msg which is set equal to 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
Inherited from MidiMsg. 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
Inherited from MidiMsg. 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
Inherited from MidiMsg. 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
Inherited from MidiMsg. dat14() returns the interpretation of the data bytes as an unsigned14-bit integer.
int bend() const
Inherited from MidiMsg. bend() returns the interpretation of the data bytes as a signed 14-bit integer.
int key() const
Inherited from MidiMsg. key() returns the key number (applicable to note on or note off messages only).
int vel() const
Inherited from MidiMsg. vel() returns the velocity (applicable to note on or note off messages only).
int len() const
Inherited from MidiMsg. len() returns the length of the entire MIDI message.
bool is_note_end() const
Inherited from MidiMsg. 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
Inherited from MidiMsg. is_ext()tells whether the message contains extended data, i.e. whether theext_data pointer ed is non-NULL.
void set_bend( float v )
Inherited from MidiMsg. 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 )
Inherited from MidiMsg. 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 )
Inherited from MidiMsg. set_data14() sets the object's data bytes to contain the 14-bit unsigned integer passed to it.
void set_chan(int c)
Inherited from MidiMsg. set_chan() sets the least significant nibble of the MidiMsg's status byte to c.
void set_key(int k)
Inherited from MidiMsg. set_key() sets the first data byte of the MidiMsg to k.
void set_key(const char* k)
Inherited from MidiMsg. This version of 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)
Inherited from MidiMsg. set_vel() sets the second data byte of the MidiMsg to v.
void set_sys_ex( uchar *r, long len )
Inherited from MidiMsg. 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 )
Inherited from MidiMsg. 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
Inherited from MidiMsg. sprint() puts a textual representation of the MidiMsg into the string pointed to by s.
UtilStringPtr unparse() const
Inherited from MidiMsg. Because 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
I'll introduce the term "note on/end pair" to refer to the messages associated with an entire note. 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
Returns true if m is equal to this MIDI_msg, and false if it is not.
MIDI_msg& operator=(const MIDI_msg& m)
Sets this MIDI_msg equal to m.

Modified 17 January 1996 pepellet@mit.edu