Generating MIDI with an AVR microcontroller
Transmitting and receiving MIDI messages and setting up the MIDI protocol
Introduction

What is MIDI and where does it stand for? MIDI is the abbreviation for Musical Instrument Digital Interface, and is a digital interface system to control MIDI devices in real time such as synthesizers, MIDI keyboards, MIDI modules, digital drummachines, MIDI samplers, and/or MIDI controllers, or any other device which can receive MIDI signals. The MIDI protocol was invented in 1982 and MIDI first introduced in 1983.


The MIDI protocol

The MIDI protocol is made up of so called messages. A message consists of series of bytes. MIDI has hundreds of such defined messages. Some messages consist of only one byte, while other messages consist of two bytes. Yet others have three bytes. A MIDI message can have as many bytes as the system requires. The common thing that all MIDI messages have is that the first byte of the message is always the Status byte. This is a special byte because it is the only byte that has bit-7 set. Any other following bytes in that message will not have bit-7 set. Thus you can always detect the start of a MIDI message, because that's when you receive a byte with bit-7 set. The Status byte is in the range of 0x80 to 0xff. The remaining bytes of the message (for example, the data bytes, if any) are in the range of 0x00 to 0x7f.