MIDI In vs. MIDI Out

The MIDI communication protocol has two main options: MIDI in and MIDI out. MIDI in refers to receiving MIDI messages as an input. MIDI out refers to sending MIDI messages as an output.

Each type requires a different circuit to send or receive the messages properly. MIDI controllers will have the ports labeled as such. For homemade devices, you will define your device as either being an input or an output.

MIDI Channels

MIDI messages are sent via channels. There are 16 available channels, numbered 1-16. The channels allow for devices to know what and who to listen to, similar to setting up a remote to control a specific television.

For example, a MIDI controller could send a C3 note and CC messages via channel 1 to a synthesizer setup to receive messages on channel 1. At the same time, that MIDI controller could send the same or different messages on channel 8 to a drum machine setup to receive messages on channel 8.

In code, these channels are numbered 0 to 15 because you are counting with zero-based numbering. For example, real-world channel 1 is coded as channel 0, real-world channel 2 is coded as channel 1, etc.

In CircuitPython, your MIDI device's channel that it is listening to or sending messages on is defined at the beginning of your code. It looks like this:

midi = adafruit_midi.MIDI(
    midi_in=usb_midi.ports[0], in_channel=0, midi_out=usb_midi.ports[1], out_channel=0)

where in_channel and out_channel are holding the channel values.

In Arduino, it's a little different. In the setup(), the begin() function is called with MIDI_CHANNEL_OMNI. MIDI_CHANNEL_OMNI means that the code is able to listen for any of the 16 MIDI channels. it looks like this:

MIDI_CREATE_DEFAULT_INSTANCE();

void setup()
{
  MIDI.begin(MIDI_CHANNEL_OMNI);
}

More discrete MIDI channel definitions can be defined when sending individual MIDI messages. Examples for this syntax are available on the MIDI Messages page of this guide.

Connections

DIN-5

The original MIDI connector is a MIDI jack, or DIN-5 connector. These are chunky, hearty connectors. Though they are becoming less common on newer devices, they are reliable and provide a straight forward connection to transmit MIDI data.

TRS-A

A newer MIDI connection standard that has been implemented is TRS-A, which utilizes a TRS audio jack to transmit MIDI data over UART. When this first began appearing, the connection was not standardized so older devices may require specialized cables for full compatibility. 

The standardized pinout for TRS-A is as follows:

  • MIDI Sink to TRS Tip
  • MIDI Source to TRS Ring
  • MIDI Shield to TRS Sleeve

This new standard allows for the reliability of a DIN-5 connector, but in a smaller and more common form factor.

Beware of TRS-B! TRS-B is a different TRS wiring that was used before TRS-A was standardized and can be found on various MIDI controllers.

MIDI over UART

When you see a connection with a DIN-5 or TRS-A connector, the device is using MIDI over UART. MIDI over UART transmits MIDI messages over the TX and RX serial connections at a baud rate of 31250.

You can use MIDI over UART to create MIDI devices using older boards with microcontrollers that do not have support for direct USB communication, such as the Atmega328. Additionally, you can have boards communicate with each other over MIDI directly using UART.

Angled shot of a Adafruit METRO 328 Fully Assembled
We sure love the ATmega328 here at Adafruit, and we use them a lot for our own projects. The processor has plenty of GPIO, Analog inputs, hardware UART SPI and I2C,...
Out of Stock

USB MIDI

USB MIDI has become more common for MIDI controllers. These devices have a configuration descriptor allowing them to be plug and play. These do not have direct compatibility with MIDI over UART devices, and, as a result, would require a converter to communicate directly. 

For MIDI over USB devices, you can use them with your computer to interface with music tech software. You can also use them with a USB MIDI Host, which allows for USB devices to interface with each other. There are aftermarket USB MIDI hosts available, as well as DIY options (you can even use a Raspberry Pi).

Many current microcontrollers have the ability to be used for DIY USB MIDI projects, including boards that are based on the ATSAMD21 (M0 Express), ATSAMD51 (M4 Express) and RP2040. All of these boards have support for both CircuitPython and Arduino.

Top view shot of Adafruit ItsyBitsy M0 Express - for CircuitPython & Arduino IDE on a white breadboard.
What's smaller than a Feather but larger than a Trinket? It's an Adafruit ItsyBitsy M0 Express! Small, powerful, with a rockin' ATSAMD21 Cortex M0...
$11.95
In Stock
Angled shot of a Adafruit Feather M4 Express.
It's what you've been waiting for, the Feather M4 Express featuring ATSAMD51. This Feather is fast like a swift, smart like an owl, strong like a ox-bird (it's half ox,...
$22.95
In Stock
Video of hand holding a QT Py PCB in their hand. An LED glows rainbow colors.
What a cutie pie! Or is it... a QT Py? This diminutive dev board comes with one of our new favorite chip, the RP2040. It's been made famous in the new
$9.95
In Stock

BLE MIDI

One of the more unique ways to transmit MIDI is over Bluetooth with BLE MIDI. BLE MIDI allows for wireless MIDI communication over Bluetooth. It can be the perfect choice for some projects that benefit from not being tethered by cables.

If you want to build a BLE MIDI project, you'll want to use an nRF52840 Express-based board, which has support for BLE.

Animated GIF showing CLUE board  displaying data from the many on-board sensors.
Do you feel like you just don't have a CLUE? Well, we can help with that - get a CLUE here at Adafruit by picking up this sensor-packed development board. We wanted to build some...
$44.95
In Stock
Angled shot of a Adafruit Feather nRF52840 Express.
The Adafruit Feather nRF52840 Express is the new Feather family member with Bluetooth Low Energy and native USB support featuring the nRF52840!  It's...
$24.95
In Stock

This guide was first published on Mar 02, 2022. It was last updated on 2022-03-02 13:24:41 -0500.

This page (How MIDI is Transmitted) was last updated on May 24, 2022.

Text editor powered by tinymce.