MIDI Implementation

There is a lot of stuff you can do with MIDI flows in Usine just with the standard modules, but MIDI messages differ in a couple of ways from most of the other flows which demand that they have to be treated a bit differently.

When you create a typical connection in Usine, the data sent is mostly either a single float value (like 0 and 1 from a switch or [min..max] from a fader) or an array containing the same type of data in all the array elements. Arrays can grow or shrink in size for instance by changing the number of steps in a Sequenced Step module, but the meaning and the data type of each element don't change.

MIDI, on the other hand:

  • With the exception of System Exclusive data (which are variable size arrays), MIDI messages are so-called "records" where a group of data belong together
  • The records mean different things and are of variable sizes, while each part of the records has a different meaning
  • The number of records per block is variable.
  • Notes comes as two separate messages, so it's up to the receiver to "connect" the Note OFF or the Note ON.

When describing MIDI messages, System Exclusive (or SysEx) data are not included unless specified. Note also that SysEx data aren't necessarily very "exclusive", as the SysEx format is also used for several additions to the original MIDI specification.

Messages through MIDI Cables vs Messages in Usine

Most MIDI documentation naturally relate to how the messages look when sent over a MIDI cable, and the most obvious difference between those descriptions and how the messages turn up in Usine is the number of bytes used.

Over the cable, a Note ON message will consist of three bytes:

  • the first one (the "message" or "status" byte) tells that this is a Note ON on MIDI channel X
  • the next byte ("data 1") tells the note number
  • the third and last ("data 2") contains the velocity information.

In Usine, however, this is represented as a record with four fields of datatype byte: On eg the midi-generator-create module you can see these represented as "chan", "msg", "data 1", and "data 2".

"chan" and "msg" represents the combination of message type and channel number in the status byte.

Other typical messages like channel aftertouch and program change have the same combination of message type and channel number in the status byte over a cable and are split the same way as Note ONs in Usine.

These two do however only have one data byte, so "data 2" is unused. Other messages like eg MDI Clock, only have one byte not containing any channel info, so in those cases only "msg" is used within Usine, while the four byte record layout stays the same.

Status and Data Bytes, Channel and System Messages

For a detailed list of the MIDI messages, you can have a look at MIDI Manufacturers Association.

In short, MIDI messages consist of one "status" byte with a value between 128 and 255 followed by 0..n "data" bytes with a value between 0 and 127. The status bytes are divided between "Channel" messages and "System" messages. The channel messages goes from 128 (NOTE-OFF on channel 1) to 239 (PitchWheel on channel 16).

System messages range from 240 (start of System Exclusive dump) to 255 (System Reset). As explained above, Usine splits the message type and channel in two, so you won't see a status byte with a value of 239. Instead that is splitted in to a message of value 224 (which over a cable would be PitchWheel on channel 1) and channel 16.

MIDI Implementation

Summary of MIDI implemetation.

Name Code number Data1 Data2
NOTE ON 144 note velocity
NOTE OFF 128 note velocity
KEY AFTERTOUCH 160 note after touch
CONTROL CHANGE 176 control number control value
PROGRAM CHANGE 192 program number -
CHAN AFTERTOUCH 208 after touch -
PITCH BEND 224 value (low part) value (hi part)
BEGIN SYSEX 240 factory ID data
MTC QUARTER FRAME 241 data (see MTC specification) -
SONG POS PTR 242 pos (low part) pos (hi part)
SONG SELECT 243 song number -
END SYSEX 247 - -
START 250 - -
CONTINUE 251 - -
STOP 252 - -

See also

version 5.2.221206

Edit All Pages