Setting up RPi MIDI and Fluid Synth (SoftSynth)

December 13, 2015

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

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.

  1. Check audio ports & levels
  2. Install MIDI UART driver
  3. Install SoftSynth
  4. 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
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


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

aconnect -io

With device numbers connect MIDI IN to SoftSynth using “aconnect xx:x yy:y” for example:

aconnect 128:0 129:0

New RPi MIDI board and a new MIDI Breakout board

December 13, 2015


I should have called this post “yet-another RPi MIDI board” as it’s includes my third iteration of a MIDI interface for the Pi. But YARMB doesn’t actually trip off the tongue 🙂

So here we have a new RPi MIDI board. Briefly its spec is:

  • MIDI IN via 5-W DIN Connector
  • MIDI OUT via 5-W DIN Connector
  • 3.3V Operation
  • HAT foot print (65 x 56mm).
  • Four fixing holes.
  • ID EEPROM (not fitted)


In addition to the RPi MIDI, there’s also a MIDI break out board (BoB) board. It’s spec is:

  • MIDI IN via 5-W DIN Connector
  • MIDI OUT via 5-W DIN Connector
  • MIDI THRU via 5-W DIN Connector
  • On board 5V Voltage Regulator
  • Size 80 x 49mm.
  • Four fixing holes.


DIY micro USB Hub for Raspberry Pi Zero

December 4, 2015

After ordering the new Raspberry Pi Zero I suddenly realised I didn’t have a suitable micro USB cable adapter to connect either a keyboard or mouse to it. Now common sense would have been to go back on-line and order either suitable cables or a suitable micro USB hub but as the maker saying goes “necessity being the mother of invention” so I decide to make my own. In this case a non-powered micro USB hub.USB_Bits

Getting the base components was easy. A quick call into a “pound” (or the equivalent dollar, euro etc.) shop got me a micro USB data/charging cable and a USB hub as shown for the princely sum of £2.


The basic tools are:

Screwdriver (flat and/or Philips)
Wire Strippers
Scalpel/Small knife
Soldering Iron


Open USB Hub case


Depending on the screws used in the USB Hub case you may need a Philips screwdriver to open the plastic USB Hub enclosure. In my case, the Hub’s plastic enclosure was clipped together and a bit of squeezing and gentle persuading with a flat bladed screw driver saw it come apart.


De-solder USB Cable


Once the USB hub is apart you should see a small PCB with a number of USB connectors and a cable. Make a note of the wire colour and positions. De-solder the existing USB wires from the PCB. Carefully apply heat from the soldering iron to the soldered wire and when the solder melts, gently lift the wire away from the PCB pad.


Prepare micro USB cable




With the wire cutters, cut the USB A connector (the bigger of the two USB connectors) off the cable. With the wire cutters or a small knife/scalpel cut back and remove about 2cm of the external cable insulation. Using the wire strippers, strip about 5mm of insulation from each of the individual wires. Finally, for each wire twist the copper strands and using the soldering iron, “tin” them and repeat for all wires.


Soldering the new cable


Remembering to use the info from the note you made earlier ;-), match the wire colour’s to the PCB pad and solder the first of the new wires from the micro USB cable back on to the USB Hub PCB. Repeat this for each of the wires in the micro USB cable. Once finished, check your work for any solder bridges and/or dry joins.


Putting it back together

Once you’re soldered all the wires back on the USB Hub PCB, reassemble it back into its plastic enclosure. You may want to add a tye-wrap to act as a strain relief for the micro USB cable.