MIDI stands for Musical Instrument Digital Interface. Messages are transferred over a serial protocol (based on UART, configured to 31250 8-N-1). The basics are described in Electrical Specification for MIDI and Arduino Tutorial.
Electrically it's not a plain UART signal end to end, though: MIDI IN drives an opto-isolator with a 5mA current loop instead of connecting directly to a UART RX pin. That's why the pinout below is asymmetric -- MIDI IN needs its own +/- current-loop pins, while MIDI OUT/THRU is a simpler direct connection (plus +5V for the far end's opto-isolator) -- and why you can't just wire a MIDI jack straight into a microcontroller's UART pins without that opto-isolator in between.
| Pin # | MIDI IN | MIDI OUT / THRU |
|---|---|---|
| 3 | ||
| 5 | IN- | IN |
| 2 | Shield | |
| 4 | IN+ | +5v |
| 1 |