A Pisound-based high quality low latency sound module


I have a MIDI keyboard and wanted a low latency and high quality sound module to go with it.

I’ve tested various options and I’ve settled on this system because of its excellent performance:

Pisound card
Raspberry Pi 4 (4GB)
Patchbox OS (3-14-2020 image)
Fluidsynth sound module app
Fluidsynth-gui (wrapper for Fluidsynth)
Various Soundfont files (sf2 only for Fluidsynth - no sfv)
A USB MIDI keyboard (I haven’t tried one with a standard MIDI connector)
Some good powered speakers

I used a keyboard, mouse and monitor plugged into the Pi for setup. Then, a VNC app (e.g., on an iPad) works well for Soundfont and instrument selection.
For VNC, you’ll need the IP address of the Pi.
$ hostname -I (capital ‘eye’)

The Fluidsynth-gui makes it really easy to select the various Soundfonts and their associated instruments. It will need one line edited (done later).

And some Soundfont files that I like. These are free from the Web. There are many others, too.

There is an excellent and realistic-sounding piano. I edited the file because the sound from the lowest three notes were left/right channel reversed.
Some Rhodes pianos.
Some organs and strings.

All four files are here:

Here are the steps to create this system. I only used WiFi (no ethernet cable). I’m in the US so the keyboard setup needed updating.

Burn the Patchbox OS image to SD card.
Install the Pisound card into the Raspberry Pi. Turn the VOLUME knob all the way up. Plug the speakers into Pisound. Plug the MIDI keyboard into the Pi.
Plug the SD card into the Pi. Power it up and do initial OS setup. This will all be repeated since there is no internet access until Wifi is set up:
Answer NO to the Patchbox OS updates (there’s no internet access yet)
Do the Wifi setup
Choose a module -> none: Default Patchbox OS environment
When this initial setup is completed, it will leave you with a command prompt.

$ startx (to start the Desktop)
Preferences - Mouse and Keyboard Settings - Keyboard - Keyboard Layout - English (US) (the default was a UK keyboard)
Open a terminal and now do the complete Patchbox setupl:
$ patchbox
wizard Initial setup wizard
Check for Patchbox OS updates - Yes
Security part
Now pick the default system sound card -> pisound
Set sample rate -> 48000
Set buffer size -> 128
Set period -> 2
Choose Boot environment -> desktop autologin
Do you want to connect to WiFi network? -> Yes
Choose a module -> none: Default Patchbox OS environment

When this finishes, reboot:
$ reboot

The OS should be in the desktop now.
Open a terminal:

$ sudo apt-get install fluidsynth
$ sudo apt-get install gedit
$ sudo apt-get install python-wxtools
$ sudo chmod 777 /usr/share/sounds/sf2/

Copy the Soundfont sf2 files to /usr/share/sounds/sf2/
I used a USB memory stick and did it through File Manager. That’s why the permissions for this folder were changed previously with chmod.
Fluidsynth comes with a General MIDI Soundfont, but it is poor quality (imo).

Copy fluidsynthgui.py to /home/patch/

$ gedit fluidsynthgui.py
and change–
self.fluidsynthCmd = ‘fluidsynth -sli -g 5 -C 0 -R 0 -p FluidSynth-GUI’
self.fluidsynthCmd = ‘fluidsynth -sli -a alsa -g 5 -C 0 -R 0 -p FluidSynth-GUI’
save and exit.

$ sudo gedit /boot/config.txt
comment out the dtparam=audio=on for this line:
# Enable audio (loads snd_bcm2835)
save and exit.

one final reboot either in the Desktop or from a terminal.
Now, open a terminal and run the Fluidsynth-gui file.
$ python fluidsynthgui.py
type in /usr/share/sounds/sf2/ for the ‘Sound Font Dir’
then select a sound font (there’s a delay when moving between Soundfonts but not between instruments within a Soundfont)
in the ‘Levels’ tab - set level to 5 (the default level of 50 caused massive distortion when hitting keys hard)

That’s it! The system should be working with really great sound.

Note that the first key press on the MIDI keyboard didn’t make any sound, but they do from then on.


1 Like

Hi Bob, that’s a great guide :slight_smile: It looks straightforward to follow.

One thing I noticed: Copy fluidsynthgui.py to /patch/ - was it meant to be copied to /home/patch/ instead?

Btw, what does the commenting out of dtparam=audio=on achieve? Is it to disable Raspberry Pi’s built-in audio through HDMI and 3.5mm jack?

Yes, the fluidsynthgui.py file should be copied to /home/patch/.

I’ve edited my original post to fix this and two other minor things.

Commenting out dtparam-audio=on in config.txt does disable audio through HDMI and 3.5mm. Hitting keys on the MIDI keyboard would result in distorted squeaks through the HDMI path so there was obviously some sort of conflict. I’m not sure exactly what was going on but removing that line fixed the issue.

1 Like