The purpose of a MIDI input optocoupler is to avoid ground problems from chassis to chassis. If I had two microcontrollers in the same circuit, one board’s UART output to the other board’s UART input, could I just invert the output with something like a 74hc14 and skip the opto? They share the same ground, seems like it shouldn’t be a problem. It would cut down on costs, build time, board complexity, and massive increase in throughput if you changed the baud rate to whatever you wanted to since you don’t need to worry about opto slew rates.
...because I'm not interfacing with any outboard gear. Let's say I generated a sequence on a mega2560 and spit it out over 3 UARTs to 3 nano based synths. They're all 5V. I don't want to set up 3 separate opto/diode/resistor circuits to do it. I'd rather just invert the outputs and feed them to the UART pins. As long as all 4 devices were set to the same baud, they'd communicate.
You could do that but it would no longer be "MIDI" and it would not work. If you invert the transmit you also have to invert the receive. If you connect it to a real MIDI system you stand the chance of frying something.
The UART signal is inverted in MIDI. Here is a link I highly recommend, it is one of sparkfun tutorials. It does a nice job explaining what is happening. MIDI Tutorial - SparkFun Learn
The UART signal is not inverted. MIDI simply uses a current loop, the schematic you linked to translates a low voltage to a ~5 mA current in the loop (and translates a high voltage to no current).
That current is then translated back to a voltage level on the other end, using the opto-isolator.
If you simply connect two microcontrollers using their UARTs directly, nothing is inverted, and you can send normal MIDI over it without issues.