I recommend using the SHARP PC900 for MIDI. It's an optocoupler with a digital output, there's a Schmitt trigger inside, so the part can be connected directly to an UART input. Used in many - if not in most - professional MIDI devices. Regards, Jarek