Ver 3: Build script for Sonic Pi 3.2.0 for Raspberry Pi

THE GREMLINS strike again. Unfortunately two vital commands were missed out in the script, which build the erlang beam files. Now added in ver2 which is shown below.

I have spent some time working on a script to enable you to build Sonic Pi 3.2.0 release tag version on Raspbian Buster.
This has been tried out on a pristine SD card containing version 2020-02-05, with sudo apt update and sudo apt upgrade applied.

The script is only about 40 lines long, and does everything, including downloading the source, plus a patch folder (from my own website), and it then builds a working version.
Included in the download is a separate install folder, which lets you install the build sonic-pi in /opt where the original versions used to be before a deb was produced. It also creates a desktop file and inserts an entry in the main memu so that you can start it from there. The install folder also contains instructions on reducing the size of the built install folder, to remove all the files whicdh are not needed after you have done the build, thus resulting in a smaller installed file. There is also a remove script which copies the sonic-pi folder back out from /opt and deletes the desktop entry.

EDIT ver 3 of script shown below. Make sure you use this one if you downloaded the first or secondversion. This version says #version 3

#!/usr/bin/env bash
#script by Robin Newman to build Sonic Pi 3.2.0 release on Raspbian Buster 2020-02-05
#version 3 with correct build of erlang beam files included
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCE_DIR=$SCRIPT_DIR/spsrc
echo $SCRIPT_DIR
echo $SOURCE_DIR

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 \
     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


mkdir -p $SOURCE_DIR
cd $SOURCE_DIR
wget https://github.com/samaaron/sonic-pi/archive/v3.2.0.tar.gz
wget http://r.newman.ch/rpi/sp32RpiPatches.tar.gz
echo "extracting Sonic Pi source.."
tar -zxf v3.2.0.tar.gz
echo "extracting patch scripts.."
tar -zxf sp32RpiPatches.tar.gz
extract install folder
mv sp32RpiPatches/spInstall ./
cd sp32RpiPatches
echo "applying patches..."
rsync -a qt/ ../sonic-pi-3.2.0/app/gui/qt/
cd ../sonic-pi-3.2.0/app/gui/qt/

echo "compiling vendor extensions..."
../../server/ruby/bin/compile-extensions.rb
echo "running unix-prebuild script..."
./unix-prebuild.sh
echo "build beam files.."
cd ../../server/erlang
/usr/bin/erlc osc.erl
/usr/bin/erlc pi_server.erl.erl
cd ../../gui/qt
echo "running unix_config script..."
./unix-config.sh
echo "building gui and sonic-pi app..."
cd build
cmake --build .
echo "build complete"

The script could be more polished, but it does the job in around 25 minutes from scratch.

ISSUES
I have noticed an erl.crashdump file being produced as the program starts. However the system works despite this. (midi and OSC all tested) This needs more investigation. It may be due to the version of erlang-base on the pi.

TRANSPARENCY
a small external script can be run to enable/disable this, which I hope to add tomorrow. There are ways of incorporating it in the system for it to be enabled automatically on startup.

OTHER LINUX
A similar script could be produced for other distro, but there are differences. Ubuntu for example needs libaubio5 to be built (at least for 18.04.4) but this is built in to the Sonic Pi source, althouhg i have disabled it on the Pi build as the apt package for libaubio5 works fine. Also I needed to install more up to date ruby and cmake on Ubuntu 18.04.

FINALLY
I would appreciate feedback on how it works.
There is further work going on to make the build process better, but this script will work with the released source at 3.2.0

3 Likes

good evening !

Tonight no raspberry pi on my side to test right now. So gonna try under ubuntu 18.04.04.

Could you tell us which version for both of them ?

CMake 3.12 or higher is required. You are running version 3.10.2
ok the script output tells me :slight_smile:

building in progress now :slight_smile:

Yes ! ! !

Thanks a lot @robin.newman !

So i can confirm your script works under ubuntu 18.04.04.

First remove the cmake too old version from your ubuntu 18.04.04 and install cmake as said before.

then copy / paste this into a file scriptInstallSpi3.2-RobinWay.sh

#!/usr/bin/env bash
#script by Robin Newman to build Sonic Pi 3.2.0 release on Raspbian Buster 2020-02-05

# nlb test for ubuntu 18.04.04 - good !


SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# you can change the name of the installation sources
SOURCE_DIR=$SCRIPT_DIR/sp_Src
echo $SCRIPT_DIR
echo $SOURCE_DIR

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 \
     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


mkdir -p $SOURCE_DIR
cd $SOURCE_DIR
wget https://github.com/samaaron/sonic-pi/archive/v3.2.0.tar.gz
wget http://r.newman.ch/rpi/sp32RpiPatches.tar.gz
echo "extracting Sonic Pi source.."
tar -zxf v3.2.0.tar.gz
echo "extracting patch scripts.."
tar -zxf sp32RpiPatches.tar.gz
#extract install folder
mv sp32RpiPatches/spInstall ./
cd sp32RpiPatches
echo "applying patches..."
rsync -a qt/ ../sonic-pi-3.2.0/app/gui/qt/
cd ../sonic-pi-3.2.0/app/gui/qt/

echo "compiling vendor extensions..."
../../server/ruby/bin/compile-extensions.rb
echo "running unix-prebuild script..."
./unix-prebuild.sh
echo" running unix_config script..."
./unix-config.sh
echo "building gui and sonic-pi app..."
cd build
cmake --build .
echo "build complete" 

then make this executable
chmod +x script scriptInstallSpi3.2-RobinWay.sh

then launch the script :
./scriptInstallSpi3.2-RobinWay.sh
Take a beer or a coffee or an English Tea

When you see build complete, go ahead and :

nlb@devbox:~/audio/robinNewmanWay$ 
nlb@devbox:~/audio/robinNewmanWay$ cd sp_Src/sonic-pi-3.2.0/
nlb@devbox:~/audio/robinNewmanWay/sp_Src/sonic-pi-3.2.0$ cd bin/
nlb@devbox:~/audio/robinNewmanWay/sp_Src/sonic-pi-3.2.0/bin$ ./sonic-pi &

you can test and play a little game of “tennis de table”

live_loop :tennis_de_table do
  use_synth :piano
  with_fx :ping_pong do
    play [:c3, :c2, :b6, :b6+0.15,
          72, 72.25,72.5, :c2-0.15].tick, sustain: 0.1
    sleep 0.5
  end
end

EDIT : No midi and osc for the moment. will see tomorrow.

Hope it works for you !

I’m out at a show tonight! Will try later. You can also amend my patches to build libaubio5 as well. Well done with your build.

yes you’re right osc and midi can’t work for now. Tomorrow ia another day. Have a good show !

I have put a different set of patches on my website and if you substitute the qt folder contained in these for the qt folder contained in sp32RPiPatches then the build should include libaubio5 which will be stored in the folder /app/server/native/lib
you can get them from wget http://r.newman.ch/rpi/sp32scripts.tar.gz
If you extract the folder tar zxf sp32scripts.tar.gz you should then use the contained folder qt instead of the qt folder inside the sp32RPiPatches folder for building on Ubuntu 18.0.4

For Ubuntu 18.04.4 I installed cmake using https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4-Linux-x86_64.sh
and installed it in /opt/cmake/cmake-3.16.4-Linux-x86_64/

I did a ln -s /opt/cmake/cmake-3.16.4-Linux-x86_64/bin/cmake /usr/local/bin/cmake

for ruby I installed rvm using this page https://github.com/rvm/ubuntu_rvm
following the instructions on the page.
I then did rvm install 2.6.3-dev
and made it the default ruby using
rvm --default use 2.6.3-dev

The packages installed I think were.

sudo apt-get install -y \
     g++  pkg-config git build-essential jackd libjack-jackd2-dev \
     libsndfile1-dev libasound2-dev libavahi-client-dev libicu-dev \
     libreadline6-dev libfftw3-dev libxt-dev libudev-dev  \
     libqt5svg5-dev qt5-qmake qt5-default libqt5websockets5-dev qtwebengine5-dev \
     qttools5-dev qttools5-dev-tools qtdeclarative5-dev libqt5webkit5-dev \
     qtpositioning5-dev libqt5sensors5-dev qtmultimedia5-dev libffi-dev \
     libqt5opengl5-dev curl python erlang-base qjackctl

I’m working on a script similar to the Raspberry Pi one to put all this together.
You also need to build supercollider and sc3-plugins. I used version 3.10.4 and
3.10.0 respectively.

Hi,

I got already on my computer scide aka SuperCollider Ide installed. version 3.9.1

So i just have installed rvm to installthe ruby version you mentioned and add your two lines and midi works

#!/usr/bin/env bash
#script by Robin Newman to build Sonic Pi 3.2.0 release on Raspbian Buster 2020-02-05

# nlb test on ubuntu 18.04.04 - midi and osc ok 



SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# you can change the name of the installation sources
SOURCE_DIR=$SCRIPT_DIR/sp_Src
echo $SCRIPT_DIR
echo $SOURCE_DIR

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 \
     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


mkdir -p $SOURCE_DIR
cd $SOURCE_DIR
# wget https://github.com/samaaron/sonic-pi/archive/v3.2.0.tar.gz
wget http://r.newman.ch/rpi/sp32RpiPatches.tar.gz
echo "extracting Sonic Pi source.."
tar -zxf v3.2.0.tar.gz
echo "extracting patch scripts.."
tar -zxf sp32RpiPatches.tar.gz
#extract install folder
mv sp32RpiPatches/spInstall ./
cd sp32RpiPatches
echo "applying patches..."
rsync -a qt/ ../sonic-pi-3.2.0/app/gui/qt/
cd ../sonic-pi-3.2.0/app/gui/qt/

echo "compiling vendor extensions..."
../../server/ruby/bin/compile-extensions.rb
echo "running unix-prebuild script..."
./unix-prebuild.sh
echo" running unix_config script..."
./unix-config.sh

echo "build beam files.."
/usr/bin/erlc ../../server/erlang/osc.erl
/usr/bin/erlc ../../server/erlang/pi_server.erl.erl


echo "building gui and sonic-pi app..."
cd build
cmake --build .
echo "build complete" 

So the situation is as this :

  • midi is detected and receive midi note and midi control change
use_synth :piano
# only one note no chords possible
live_loop :test_midi do
  use_real_time
  note, velocity = sync "/midi:apc_key_25_midi_1:5:2/note_on"
  puts note
  play note
  sleep 0.125
end
  • can’t send midi note or maybe because the new syntax
  • osc seems not to work

Could you tell me if i have missed a step for osc to work ?

Yes there is a mistake in the script…however I am just doing final testing on a similar script dedicated to installing in Ubuntu18.04.4 Hopefully published tomorrow.

In the meantime I think that the beam files are probably not set up for you.
You can do this by navigating to sp-source/app/server/erlang
then running

/usr/bin/erlc osc.erl
/usr/bin/erlc pi_server.erl

That should produce files osc.beam and pi_server.beam
Then try running again.

1 Like

Great ! ! ! ! Solved : osc is working and midi can send notes !

"Last night @robin.newman saved my life with that script "

Thanks for all your work and patience !

I’ve followed this build process on ubuntu 19.10 using the script posted by @robin.newman 29/2, and revised with the update posted by @robin.newman Mar 1.

I now have a working spi3.2 on ubuntu 19.10 with OSC working. Great work by everyone and thank you all very much.

I am not able to control spi using sonic-pi-tool.py ( python cli for sonic-pi https://github.com/emlyn/sonic-pi-tool which (mostly) works on earlier versions of sonic-pi. I’ve put more information on this posting http://in-thread.sonic-pi.net/t/what-spi-3-2-control-port-to-use-for-cli-tool/3433

see this answer here

Hi @nlb, hi @robin.newman

I tried to run your @nlb’s script based on Robin’s work, and get (last 13 lines of the otherwise seemingly successful run of the script):

Scanning dependencies of target sonic-pi
[100%] Building CXX object CMakeFiles/sonic-pi.dir/sonic-pi_autogen/mocs_compilation.cpp.o
[100%] Linking CXX executable sonic-pi
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In Funktion »_start«:
(.text+0x20): Warnung: undefinierter Verweis auf »main«
collect2: error: ld returned 1 exit status
CMakeFiles/sonic-pi.dir/build.make:92: recipe for target 'sonic-pi' failed
make[2]: *** [sonic-pi] Error 1
CMakeFiles/Makefile2:98: recipe for target 'CMakeFiles/sonic-pi.dir/all' failed
make[1]: *** [CMakeFiles/sonic-pi.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
build complete

The result is that:

/app/gui/qt/build/sonic-pi

will not be build.

Any suggestions?

Note: The german warning “Warnung: undefinierter Verweis auf …” says something like: “Warning: undefined reference to …”

Are you building on Ubuntu 18.04.4? or on Raspbian Buster?

Oh, sorry… I am building on Ubuntu 18.04, Bionic Beaver (actually Mint 19.3 based on that).

Right now my actual goal is to build a version based on the latest developement tree, because of Runtime - temporarily patch memory leak (partially) and my hope is that this will fix some issues for an upcoming gig (this is really hazardous, I know, but isn’t live coding this anyway, plus: if all breaks I have another system to boot with a SP 3.1 which is at least enough to make music :wink: ) I don’t even need Midi and/or OSC.

I’ve just built the latest version of the distribution successfully on Ubuntu18.04.4
I am using ruby-2.6.3-dev installed via rvm
I am also using cmake 3.16.4 installed from a binary.
I think I had to install a ruby bundler gem to get the new fast-osc version to build. Also, compile-extensions tries to build the gem interception but stops the program. It is the last vendor gem processed and in fact doesn’t need building so it doesn’t matter.
Other than that I used my script.
Looking at the errors you have.

CMakeFiles/sonic-pi.dir/build.make:92: contains 
sonic-pi_autogen/EWIEGA46WW/qrc_SonicPi.cpp: ../images/toolbar/default/dark-size-up.png

Don’t know if this is helpful. They are dynamically built files and may well differ in your case.

But at least my experience is that the build should be possible.

Hi Robin,

thanks for the feedback. I did not update Ruby (currently using 2.5.1p57), maybe that’s it? Well, I will do and try again this afternoon.

Yeah. It works (I guess because I did install the latest Ruby, which I skipped before). I still have to test but seem to have a running 3.2… now. Thanks Robin!

1 Like

Great. Well done. It will be interesting to hear your comments on memory leaks with the work that has gone on to reduce it,

Yes, will be one of the first things to look at…

EDIT: Seems to be much, much better now :slight_smile: .

2 Likes