Building SP3.2dev from source on a Pi4

At present the Raspbian Buster distribution which is necessary to run a Pi4 ships with a very old version of Sonic Pi (2.10). For those used to using version 3.0.1 on the earlier Rasbian Stretch distro on earlier Pi versions this is a frustration.
In time a new .deb file may be developed for Buster, and there has been correspondence elsewhere about the problems of this happening.
In the meantime, for those who are prepared to build Sonic Pi 3.2dev from source this is perfectly possible, and the performance of this version on a Pi4 makes it well worth the effort. However please note that this is a development version which does have some glitches still to be ironed out, and as such it is NOT a build that can be supported by Sam Aaron, (or indeed by myself), although there are probably those on this forum who may be able to help if necessary.
I have produced some instructions which will enable you to build Sonic Pi3.2dev on a pristine install of Buster release date 2019-07-10 with

sudo apt update
sudo apt upgrade


I built it on a 4Gb RAM version. The final build will certainly work on 1 and 2Gb machines, but on the former you may have to temporarily increase the swap file size. Seethis article for details. You can swap it back again afterwards.
The whole build process takes about 30 minutes to complete.
It is designed to coexist with the installed Sonic Pi version, and it probably best to leave this installed. If you remove it, you have to reinstall two packages to get the 3.2 version running.
Some of the instructions can merely be copied and pasted into a terminal window. However there are a couple of bits that need to be manually completed involving use of a text editor.
Start a terminal window in the Pi user home folder, then copy and paste in the section below, which will:

  • install extra packages required
  • create a src folder and download sonic pi source files into it.
  • add osmid source files to the src folder
  • build the m2o and o2m binaries in osmid
  • install the binaries
  • build the two erlang files from osc.erl and pi_server.erl
  • install rugged-0.28.2 gem and copy it into the sonic pi ruby/vendor folder
#now install extra packages needed to build Sonic Pi
sudo apt-get install -y \
     g++ ruby ruby-dev pkg-config git build-essential libjack-jackd2-dev \
     libsndfile1-dev libasound2-dev libavahi-client-dev libicu-dev \
     libreadline6-dev libfftw3-dev libxt-dev libudev-dev cmake libboost-dev \
     libqwt-qt5-dev libqt5scintilla2-dev libqt5svg5-dev qt5-qmake qt5-default \
     qttools5-dev qttools5-dev-tools qtdeclarative5-dev libqt5webkit5-dev \
     qtpositioning5-dev libqt5sensors5-dev libqt5opengl5-dev qtmultimedia5-dev libffi-dev \
     curl python erlang-base libssl-dev libaubio5 supercollider-server

#create folder src in Pi home folder
mkdir -p ~/src
cd src
#install sonic-pi source (latest)
git clone

#install source for osmid, and build m2o and o2m     
git clone || true
cd osmid
git checkout tags/v0.6.8
mkdir -p build
cd build
cmake ..

#add installation folder in Sonic Pi
mkdir -p ../../sonic-pi/app/server/native/osmid/
#copy over the two binary images
cp m2o ../../sonic-pi/app/server/native/osmid/
cp o2m ../../sonic-pi/app/server/native/osmid/

#build the two erlang beam files
cd ~/src/sonic-pi/app/server/erlang
erlc osc.erl
erlc pi_server.erl

#install rugged gem file
cd ~/src
sudo gem install rugged -v ="0.28.2" #takes some time

#copy installed gem to sonic-pi vendor folder
cp -r /var/lib/gems/2.5.0/gems/rugged-0.28.2 ~/src/sonic-pi/app/server/ruby/vendor/ 

The installation of the rugged gem file is a bit of a bodge. The earlier version 0.26.0 did not work, and I had difficulty building the later version with the sonic pi compile-extensions.rb file. The solution was to use gem install to install it normally, and then to copy the installed (and compiled) gem over to Sonic Pi. As a result we do NOT want compile-extensions.rb to attempt to build rugged, so we need to comment out the relevant line to prevent this. Also, the compile program first clears all extension libraries which are installed in teh rb-native folder in a sub folder 2.5.0 related to the ruby version in use. So we use the amended compile-extesions.rb file to build the other extensions, and then copy in the file to join them.

  • Open the text editor in the Menu=>accessories section
  • Use the File=> Open command and navigate to
  • Pi=>src=>sonic-pi=>app=>server=>ruby=>bin
  • and open compile-extensions.rb
  • From the options Menu select Line Number
  • go to line 45 and comment it out by adding a # at the beginning of the line, which should them read:
    #File.expand_path(File.dirname(__FILE__) + '/../vendor/rugged-0.26.0/ext/rugged'),
  • resave the file

The remainder of the installation can now follow from the terminal. Copy and paste the next section which will:

  • run the modified compile-extensions.rb
  • copy in the file to the rb-native/2.5.0 folder
  • build the documentation translation files
  • prepare a fresh header for the ruby help files header
  • populate the new ruby_help.h file using qt-doc.rb
  • complete the preparation of the translation files listed in using lrelease
  • prepare the Makefile using qmake and
  • do the compilation of sonic pi using make. This last section will take a long time
#The rest of the build process is carried out in a terminal window from the qt folder

cd ~/src/sonic-pi/app/gui/qt
#compile the remaining vendor gems from qt
#note this also creates the folder ../../server/ruby/rb-native/2.5.0
#you will notice several warnings during this process but that is normal

#now complete the bodge by adding the precompiled rugged libarary to the correct location
cp ../../server/ruby/vendor/rugged-0.28.2/ext/rugged/ ../../server/ruby/rb-native/2.5.0/

#now start building the documentation
#first the translation files
../../server/ruby/bin/i18n-tool.rb -t

#prepare a fresh header for the help file compilation
cp utils/ruby_help.tmpl ruby_help.h
#populate the header file with qt-doc.rb
../../server/ruby/bin/qt-doc.rb -o utils/ruby_help.h

#now complete the preparation of completed translation files
#listed in the file

#prepare the Makefile using qmake

#do the compilation of sonic pi
make #this takes quite a bit of time

Hopefully at this stage you have completd a working Sonic Pi3.2dev
To test it, in your terminal window type


You should see the sonic pi logo in the terminal window and a splash screen will open.
After about 20 seconds you should see the main Sonic Pi window opening.

for a clean exit right click the Sonic Pi icon in the taskbar and choose Close Window.
Note although the window will close immediately the app takes about 19 seconds seconds to completely close down, so don’t try to restart it immediately.

Further work, to add an icon to start Sonic Pi3.2 from the maim menu.
It is easy to add a second SOnic Pi icon to the application menu as follows:
from a terminal type:

sudo cp /usr/share/pixmaps/sonic-pi.png /usr/share/pixmaps/sonic-pi3.2.png
# edit the new desktop file using nano:
sudo nano /usr/share/applications/sonic-pi3.2.desktop

Change the contents of the editor window to the version shown below. Essentially adding 3.2 three times

[Desktop Entry]
Name=Sonic Pi 3.2
Comment=Learn programming and computer science while creating music

Type ctrl+X followed by Y return to exit, saving the file with its existing name
(Note I used a duplicate icon, in case the original Sonic Pi is uninstalled so tha the second icon remains.)

Now generate a launcher file to place in /usr/bin
paste the folliowng

cd /usr/bin
sudo nano sonic-pi3.2

Tyoe ctrrl+X then Y return to exit
Finally make the file executable:

sudo chmod +x /usr/bin/sonic-pi3.2

You should now find a Sonic Pi 3.2 icon in the Applications Menu Programming Section underneath the original Sonic Pi icon. Clicking it should launch Sonic Pi 3.;2dev

Note if you want to move the sonic-pi folder in the src somewhere else, having completed the build then you can do so. You just have to amend the path in the sonic-pi3.2 file in the section above to suit. (change the /home/pi/src/sonic-pi/bin/sonic-pi to give an absolute path to the new location)

Some notes on the installation

This is a development version, and it has one or two known bugs/problems

The transparency slider in the Preferences panel is currently visible, but has no effect. IF it is not possible to get it working with a Pi, then it will be removed before the final version.

Even though it is ticked as enabled in the IO prefs section, OSC messages don’t work
until you disable and then re-enable the OSC Server

It is possible to run Sonic Pi using an externally setup jack server using QjackCtl.
This is of great use if you want to connect inputs from a sound card like PiSound,
which can also work with reduced latency by adjusting the connection parameters.
It can also let you connect the audio output of Qsynth or Helm synths
running on your Pi directly to Sonic Pi, even if you don’t have a sound card.
I will detail this later in a separate article.

Note Sonic Pi does NOT stop the current jackd when it quits, (in case you are using an external version).
Consequently you must issue killall jackd if you have started Sonic Pi with the internal call to jackd BEFORE you can subseqeuntly use QjackCtl.
qjackctl IS already installed on Buster but is hidden on the Applications Menu.
To enable it, select Main Menu Editor from the Preferences Section, navigate to the Sound & Visual section, and tick QjaclCtl to enable it.

If you uninstall the original Sonic Pi (ver 2.10) (which I don’t recommend) then it will also remove ruby and supercollider-server packages.
In this case you will have to reinstall them using
sudo apt install ruby supercollider-server
for Sonic Pi3.2dev to work.

Although this install has been created on a Pi4, the SD card can be transferred to a Pi3B+where it will work quite happily. It should also build on this Pi model, although it may take a lot longer, and I suspect you may have to temporarily increase the swap file size as mentioned at the beginning of this post.

Occasionally things can go wrong and Sonic Pi doesn’t exit cleanly and clean up it various components. One way to do this is to reboot the machine. More easily in ` terminal:

killall m2o
killall o2m
killall beam.smp
killall scsynth
killall ruby

should clobber everything. (You will get not found messages for thse that are already closed)

Transporting Sonic Pi3.2dev to a different SD card
Having built Sonic Pi3.2 it is possible to slim down a copy the final folder, and then move this to another Raspbian Buster SD card. With the addition of three packages, and adding the desktop files this will then work there, without having to build it again. At a later date I will give fuller detains plus some scripts to automate the process.

I hope that this post will be useful. I would welcome feedback on its use, so that it can be amended if necessary.

1 Like

OK. I’m going to give this a go now. I don’t have a clean install, but I did update and upgrade everything the other day.

I did the install as described above and everything worked fine. The only variation I made to the process was to use vi for editing in the terminal :slight_smile:

I haven’t added a main menu (in your text you say ‘maim menu’ :slight_smile:) icon yet. I’m satisfied that it’s running.

Admittedly, in terms of testing, I only went as far as running a fairly basic live_loop. But, that worked fine.

Glad you’ve got it going. Have fun with it!

1 Like