The first part of this post are some instructions I wrote back in 2014 (more here)
NOTE: Setting the 31250 baud-rate this way only works for Raspbian kernel 3.18.11, the newer kernel Raspbian 4.xx has some issues.
Getting a MIDI 31250 Baud Rate on a Pi is not easy as it should be as 31250 is not a standard Pi baud-rate. But you can trick your Pi into it if you overclock (or rather underclock) the UART clock.
Start a terminal session and type:
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.
Once saved reboot your Pi.
Next we need to stop the serial UART being used by Raspbian for the shell console. Check my previous post “MiniPIiio RS232 set-up” on how to do this.
Finally we need to add the following to “cmdline.txt”
Once we’ve done this we can get on with installing the MIDI UART driver and the SoftSynth.
- Check audio ports & levels
- Install MIDI UART driver
- Install SoftSynth
- Get MIDI IN talking to SoftSynth
Open up a terminal window and first..
1. Check audio ports and levels
Use HDMI audio for sound
amixer cset numid=3 2
Check the volume if needed
2. Install MIDI UART Driver
sudo apt-get install libasound2-dev wget http://www.varal.org/ttymidi/ttymidi.tar.gz tar -zxvf ttymidi.tar.gz cd ttymidi/
We need to modify the make file for the Raspberry Pi, so lets
sudo nano Makefile
add -lpthread to line
gcc src/ttymidi.c -o ttymidi -lasound
so it looks like
gcc src/ttymidi.c -o ttymidi -lasound -lpthread
save file with “ctrl-x” and “Y”
Lets run the Make file and install binary
make sudo make install
3. Install Fluidsynth
sudo apt-get install fluidsynth
err, that’s it just wait into it downloads and installs its self.
4. Get MIDI IN talking to SoftSynth
Start MIDI UART driver
ttymidi -s /dev/ttyAME0 -b 38400 &
Start the SoftSynth
fluidsynth --audio-driver=alsa /usr/share/sounds/sf2/FluidR3_GM.sf2
Check what devices they are listed as
With device numbers connect MIDI IN to SoftSynth using “aconnect xx:x yy:y” for example:
aconnect 128:0 129:0