That is very difficult. The serial port can be programmed at certain baudrates, which normally vary between 300 Bauds (or so) to 115200 (230400, and 460800 on more recent machines). Most all speeds are however multiples:
300, 600, 1200, 2400, 4800, etc. MIDI however is 31250 Bauds, which is difficult to program, as the there is no 'harmonic' relation. As this is fixed in the PC (and different from the Atari), it represents a serious problem.
Another issue is that MIDI is a current-loop circuit (with opto-couplers), while RS232 works with voltages. You will have to make an external interface to make the compatible.
Then, the final hurdle is the software: Managing the UART is relatively easy, and there are plenty of examples (look for the 'serial programming how-to'. The issue here appears that you probably want to present some standard interface to the MIDI-managing music programs out there. So, your driver will have to manage the UART side, and present the correct interface to the software.
Most modern MIDI interfaces also present timing with the MIDI code to the user program, so that is an extra problem.
So, it is by far easier to buy a cheap USB-to-MIDI interface!