I noticed a project at Raspberry Pi was having to use a microcontroller to buffer 38400 Baud serial port data down to the Midi standard of 31250. As part of an ongoing larger project I solved this problem by changing init_uart_clock = 2441406 in /boot/config.txt on the raspberry Pi.
My proto-type MIDI hardware is the usual 6N138 opto isolator for the MIDI Input and a 7414 for the output shown below. The output from the6N138 is 3.3v and the output from the 7414 is at 5V. This was chosen because although the MIDI specification usually talks about the signal as a current loop, there are a few devices that are MIDI powered and require 5v. MIDI powered devices work by doing away with the opto-isolater and the safety it provides.
There are a couple of changes that are needed as by default, Raspbian "wheezy" Linux distro, sets it up a serial port tty. Using a consol make these changes can be made as follows.
sudo nano/boot/cmdline.txt
Edit the line
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
to
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
exit saving the changes
Next by changing init_uart_clock=3000000 to init_uart_clock=2441406, all baud rates will be reduced by about 81%. This is not an ideal solution as if you wanted to use the serial port for other projects all the standard baud rate timings would be out by 19%. However, from a MIDI point of view you can simply open /dev/ttyAMA0 at 38400 baud and you are up and running.
Again using a consol.
sudo nano /boot/config.txt
Add these lines to the end of the file
# change uart clock to 2441406 for midi 31250 baud rate
init_uart_clock=2441406
init_uart_baud=38400
save and exit, and reboot the Pi.