Sonic Pi on Ubuntu 21.04
I went to a Sonic Pi workshop at the Peckham Digital “creative computing festival” yesterday, which meant that I had to get Sonic Pi running on my laptop first.
There are packages for Windows and Mac OS, and as the name suggests, for the Raspberry Pi, but for Linux you’re on your own a bit if you want to use the latest version. There are some build instructions but I had to make a couple of changes to get it to work.
My experience of mixing PulseAudio and JACK has never been particularly smooth, so I decided to try sidestepping the issue by installing PipeWire instead. PipeWire supports PulseAudio and JACK applications simultaneously, which should avoid all the hassles, as long as it works. The good news is that it does seem to work well.
I installed PipeWire from a PPA according to a couple of posts: setting up the PPA and installing PipeWire. The PPA probably isn’t essential, as a slightly older version is already in the Ubuntu repository for 21.04 (aka “hirsute”), but here’s what I did:
sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream sudo apt install pipewire pipewire-audio-client-libraries systemctl --user --now disable pulseaudio.service pulseaudio.socket systemctl --user --now enable pipewire pipewire-pulse
And then I rebooted to get sound to work again. There may be a way around that; I didn’t find it.
I had to install a slightly different set of prerequisites for Sonic Pi than
were listed on the build instructions.
qt5-default no longer exists, but
qtdeclarative5-dev provided what was missing.
I didn’t bother with
pulseaudio-module-jack because I’m using PipeWire.
sudo apt install \ alsa-utils build-essential cmake compton erlang-base erlang-dev \ erlang-tools git libasound2-dev libaubio5 libjack-jackd2-0 \ libjack-jackd2-dev libqt5concurrent5 libqt5concurrent5 libqt5core5a \ libqt5gui5 libqt5network5 libqt5opengl5 libqt5printsupport5 libqt5svg5 \ libqt5svg5-dev libqt5widgets5 librtmidi-dev libssl-dev \ qtbase5-dev qtdeclarative5-dev qttools5-dev-tools ruby-dev \ sc3-plugins-server supercollider-server
I then checked it out
git clone https://github.com/sonic-pi-net/sonic-pi.git
(I built at commit
4669798a0, so if you have trouble with whatever is the
main, you can try
git checkout 4669798a0 for a known good version.)
From then on, I built the application as in the instructions:
cd sonic-pi/app ./linux-prebuild.sh ./linux-config.sh cd build cmake --build . --config Release
Launching Sonic Pi
If you want the app to be available from the desktop launcher, put a file like
/home/paul/src to wherever you put Sonic Pi):
[Desktop Entry] Type=Application Name=Sonic Pi Icon=/home/paul/src/sonic-pi/app/gui/qt/images/icon.png Exec=/home/paul/src/sonic-pi/bin/sonic-pi Terminal=false
With the configuration of PipeWire above, it should automatically be used
for JACK applications. You can test this using
ldd /usr/bin/scsynth | grep jack
You should see something referring to
libjack.so.0 => /usr/lib/x86_64-linux-gnu/pipewire-0.3/jack/libjack.so.0 (0x00007f5806ff4000)
If not, you’ll have to prefix the command to run Sonic Pi with
it wasn’t necessary for me.