midi_specification
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| midi_specification [2006/04/22 11:11] – audiocommander | midi_specification [2012/10/02 06:42] (current) – Reverting spam from lauraholden cheater | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== MIDI Specifications ====== | ====== MIDI Specifications ====== | ||
| - | The [[MIDI]] Protocol constists of a package list, that normally contains one or more packages. Each Package | + | If you'd like a simplified explanation, |
| - | The //First Byte// | + | [[MIDI]] |
| - | The //Second Byte// | + | Here a short overview: each message begins with a status byte, where the 8th (leftmost) bit is set. Thereafter additional data bytes are sent, where the leftmost bit is always zero. Accordingly, |
| - | The //Third Byte// | + | The number of bytes which have to follow |
| - | **Here's an Example:**\\ | + | Some MIDI messages like RPN, NRPN and Pitch Bender allow to combine two 7bit values to a 14bit value. This extends the value range to 0-16383 (decimal) or 0x0000-0x3FFF hexadecimal - more than enough for todays synthesizers (most of them still only support 7bit resolution). |
| - | 1st Byte 144 (0x90): | + | |
| - | 2nd Byte 65 (0x40): A Note\\ | + | MIDI bytes are mostly displayed in hexadecimal form to simplify the reading. Therefore we will continue with this value format below, and won't mention the appr. decimal values anymore. |
| - | 3rd Byte 100 (0x64): Velocity 100\\ | + | |
| + | Status bytes in the range of 0x80..0xEF contain a channel information, | ||
| + | |||
| + | For Example: | ||
| + | | ||
| + | 0x91 identifies a Note On event at the second Channel | ||
| + | ... | ||
| + | 0x9F identifies a Note On event at the 16th Channel | ||
| + | |||
| + | Thanks to this coding, it's very simple to identify the Channel, just read the rightmost hexadecimal digit. | ||
| + | |||
| + | The last 4 bits (leftmost hexadecimal digit) identifies the MIDI event type: | ||
| + | 8: Note Off | ||
| + | 9: Note On | ||
| + | A: Polyphonic Key Pressure | ||
| + | B: Control Change (CC) | ||
| + | C: Program Change | ||
| + | | ||
| + | E: Pitch Bender | ||
| + | |||
| + | Follow this [[http:// | ||
| + | |||
| + | |||
| + | F identifies a System Message which either addresses all listeners | ||
| + | |||
| + | E.g., MIOS "feels addressed" | ||
| + | [[SysEx]] messages should be finished with 0xF7, thereafter any other MIDI event can be sent again. | ||
| + | |||
| + | The last Status Bytes within the range of 0xF8..0xFF - also called " | ||
| + | |||
| + | A typical realtime message is the MIDI clock 0xF8 - since it is allowed to send the clock at any time, regardless of the currently sent stream - the achievable latency is very low. In addition, realtime messages don't change the running status - more about this topic (status byte can be omitted if the same one was sent before) can be read in the MIDI spec. | ||
| + | |||
| + | |||
| + | \\ | ||
| + | \\ | ||
| + | |||
| + | ====== Programming Examples ====== | ||
| + | |||
| + | At the end some practical informations for MIOS programmers | ||
| + | |||
| + | MIDI bytes are sent with the MIOS_MIDI_TxBufferPut() function: | ||
| - | If you want to send this message with MIOS (programmed in [[C]]) it would look like this: | ||
| <code c> | <code c> | ||
| - | MIOS_MIDI_BeginStream(); | + | MIOS_MIDI_TxBufferPut(0x90); |
| - | MIOS_MIDI_TxBufferPut(0x90); | + | MIOS_MIDI_TxBufferPut(0x40); |
| - | MIOS_MIDI_TxBufferPut(0x40); | + | MIOS_MIDI_TxBufferPut(0x64); |
| - | MIOS_MIDI_TxBufferPut(0x64); | + | </ |
| - | MIOS_MIDI_EndStream(); | + | |
| + | will send a Note On event at Channel 0 (first channel, in most MIDI applications called Channel #1 when they are counting from 1). The Note number is 0x40 (E-3), the velocity is 0x64 | ||
| + | |||
| + | The appr Note Off event starts either with 0x80, or with 0x90 (running status optimisation) and velocity 0x00: | ||
| + | |||
| + | <code c> | ||
| + | MIOS_MIDI_TxBufferPut(0x90); | ||
| + | MIOS_MIDI_TxBufferPut(0x40); | ||
| + | MIOS_MIDI_TxBufferPut(0x00); | ||
| + | </ | ||
| + | |||
| + | |||
| + | Other typical MIDI events are Controllers (CC), they begin with 0xbn (n = Channel): | ||
| + | |||
| + | <code c> | ||
| + | MIOS_MIDI_TxBufferPut(0xb8); | ||
| + | MIOS_MIDI_TxBufferPut(0x01); | ||
| + | MIOS_MIDI_TxBufferPut(0x7f); | ||
| + | </ | ||
| + | |||
| + | |||
| + | If the MIDIbox Link mechanism should be used to tunnel MIDI events through the MIDIbox Link Endpoint, a MIDI stream has to be framed by a begin and end function in the following way: | ||
| + | |||
| + | <code c> | ||
| + | MIOS_MIDI_BeginStream(); | ||
| + | MIOS_MIDI_TxBufferPut(0xcf); | ||
| + | MIOS_MIDI_TxBufferPut(0x02); | ||
| + | MIOS_MIDI_EndStream(); | ||
| + | </ | ||
| + | |||
| + | |||
| + | And the last example shows, how to save MIDI bandwidth (the transmission of a single byte takes 320 uS) by using the Running Status feature (as mentioned above: so long the following status bytes are equal, we can omitt them): | ||
| + | |||
| + | <code c> | ||
| + | | ||
| + | MIOS_MIDI_TxBufferPut(0x90); | ||
| + | MIOS_MIDI_TxBufferPut(0x3c); | ||
| + | MIOS_MIDI_TxBufferPut(0x7f); | ||
| + | MIOS_MIDI_TxBufferPut(0x40); | ||
| + | MIOS_MIDI_TxBufferPut(0x60); // velocity | ||
| + | | ||
| + | MIOS_MIDI_TxBufferPut(0x40); | ||
| + | | ||
| </ | </ | ||
| - | More informations can be found online:\\ | ||
| - | [[http:// | ||
| - | * [[http:// | ||
| - | * [[http:// | ||
| - | * [[http:// | ||
| \\ | \\ | ||
| + | \\ | ||
| + | |||
| + | ====== 14-bit MIDI Messages ====== | ||
| + | |||
| + | There are two ways to use 14-bit MIDI Messages; the trick is, to combine two 7-bit Messages to one 14-bit: | ||
| + | <code c> | ||
| + | unsigned int MSB = 127 << 7; // 16256 | ||
| + | unsigned char LSB = 127; // 127 | ||
| + | unsigned int largeNumber = MSB + LSB; // 16383: | ||
| + | </ | ||
| + | * using RPNs | ||
| + | * using NRPNs: <code c> | ||
| + | CC98 01100010 0x62 Non-Registered Parameter Number (NRPN) - LSB 0-127 LSB | ||
| + | CC99 01100011 0x63 Non-Registered Parameter Number (NRPN) - MSB 0-127 MSB | ||
| + | </ | ||
| + | * sending two Controller Messages, eg:< | ||
| + | CC 12, Effect Ctrl 1 (MSB = Most Significant Byte) | ||
| + | CC 44, Effect Ctrl 1 (LSB = Least Significant Byte)</ | ||
| + | |||
| + | Sending 14bit from one pot is only possible if you're hacking the code. Because Pots are being read as 10-bit value, you have to interpolate to 14 bit and implement a NRPN or dual-CC method. | ||
| + | |||
| + | Further informations: | ||
| + | [[http:// | ||
| + | [[http:// | ||
| + | |||
| + | |||
| + | \\ | ||
| + | \\ | ||
| + | |||
| + | ====== Tools & Helpers ====== | ||
| + | |||
| + | [[ACMidiDefines]] – a definition listing to access Midi Events by Name | ||
| + | |||
| + | |||
| + | \\ | ||
| + | \\ | ||
| + | ====== More Informations ====== | ||
| + | |||
| + | More informations can be found online:\\ | ||
| + | |||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | |||
| + | |||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | |||
| + | |||
| + | * [[http:// | ||
| - | [[http:// | + | * [[http:// |
| - | [[http:// | ||
midi_specification.1145704313.txt.gz · Last modified: 2006/10/15 09:35 (external edit)
