Introduction to Midi Programming
Intro – Format of Midi Messages
MIDI (Musical Instrument Digital Interface) messages consist of a header and a data part. The format is as follows:
Header
- Status byte: This 1-byte value indicates the type of message being sent:
0x80-0xF7: Control Change, Pitch Bend, or Program Change (CC, PB, PC)0xF8-0xF9: Note On, Note Off, or Poly Aftertouch (NO, NOF, PAF)0xFA-0xFC: System Exclusive, Meta Event, or Timing Clock (SX, ME, TC)
- Channel: This 1-byte value specifies the MIDI channel (1-16) for messages that affect multiple channels.
Data Part
The data part varies depending on the status byte:
Control Change (CC), Pitch Bend (PB), and Program Change (PC)
0x00-0x7F: Control number (e.g., volume, pan)0x80-0xFF: Value of the control (0-127) or pitch bend amount (0-16383)
Note On (NO), Note Off (NOF), and Poly Aftertouch (PAF)
0x00-0x7F: Note number (0-127)0x80-0xFF: Velocity (0-127) for Note On and Note Off, or aftertouch pressure (0-127) for Poly Aftertouch
System Exclusive (SX), Meta Event (ME), and Timing Clock (TC)
These messages typically contain a variable-length data payload that’s specific to the system or device.
Example MIDI Message
Here’s an example of a Note On message:
Status byte: 0x90 (Note On, channel 1)
Channel: 0x00 (channel 1)
Data part:
* Note number: 0x3C (Middle C)
* Velocity: 0x40 (medium velocity)
MIDI message: 0x90 00 3C 40
Keep in mind that this is a simplified example, and actual MIDI messages can be more complex, depending on the specific device or system being used.
