Goal: Install and use SuperCollider to make music.
Difficulty: Easy
Required Hardware: #List all needed hardware things & components
- Pisound
- Raspberry Pi
Background
SuperCollider is a platform for audio synthesis and algorithmic composition. it is open source, and very mature.
You have two choices… install version 3.7.0 which is in the package repos. This is easy, but a little older. Or compile it yourself, but that’s a bit harder and will take an hour or more.
Just install it…
Install with
sudo apt-get install --no-install-recommends supercollider
Note: This is a much smaller install than what the pisound-config
installs.
You will get a dialog box with a lot of text, asking you, at the end “Enable realtime process priority?”. Choose
Yes
Set up
SuperCollider talks to jackd
, which in turn talks to alsa
. You can let SuperCollider handle starting and stopping jackd
for you, but you need to set it up.
Edit (vi
or emacs
or nano
) the file ~/.jackdrc
to have the following single line:
/usr/bin/jackd -R -P 75 -d alsa -d hw:pisound -r 48000 -n 2 -p 64 -s
Run it
From a shell in a desktop on the Pi:
scide
Once running, you need to boot a server: From the Language menu, choose Boot Server. You’ll see some text which should let you know that jackd
is running with ALSA
.
Then type some SuperCollider code into the big, Untitled window, select it, and choose Language menu > Evalutate Selection, Line, or Region. (Or type [CTRL+Return]
)
Try this lovely snippet from Fredrik Olofsson:
play{q=SinOsc;a={|x...y|perform(x,\ar,*y)};Splay ar:a.(CombN,c=a.(q,0,a.(Blip,1/f=(1..8),888/a.(q,1/88,0,2,3).ceil*a.(Duty,a.(q,1/8)>0+2*1/8,0,Dseq([8,88,888],inf)))*188),1,8-f/8,8)/8+a.(CombN,a.(GVerb,a.(BPF,8*e=c.mean,88,1/8),88),1,1)+a.(q,88,0,a.(q,0,e)<0/88)}// #SuperCollider
He’s @redFrik on twitter, and he posts many great short compositions you can play in SuperCollider.
To stop, Language > Stop. (or just [CTRL+.]
.)
If you want to test input effects processing, try this:
{
var fast = SinOsc.kr(12) * 2; // +/- 2 semitones at 12Hz
var slow = SinOsc.kr(0.2) * 24; // +/- 2 octaves at 1/5Hz
var center = 60; // around middle C
var filtFreq = (fast + slow + center).midicps;
var input = SoundIn.ar();
var resonated = Resonz.ar(input, filtFreq, bwr:0.15);
var reverbed = FreeVerb.ar(resonated, room:0.8);
reverbed // last thing returned is played out
}.play
Plug your guitar, or mic, or synth into the Pisound input, and headphones or your stereo into the output.
Build it…
The advantage of building SuperCollider is that you can run a newer or development version. The downside is that it is not for the faint of heart. You should be familiar with building software on Linux, and ready to handle thing is they go south.
Difficulty: Moderate
Getting ready
SuperCollider maintains instructions for building on RaspberryPi. That page has several options, and a fair bit of detailed information. The instructions here are a “this just works” approach, and are a bit simpler.
Get the source
Run the following:
git clone --recursive git://github.com/supercollider/supercollider
cd supercollider
Decide which version you are going to build, and run one of the following:
get checkout master # latest stable code in development
get checkout 3.10 # latest in the 3.10 branch
get checkout 3.9 # latest in the 3.9 branch
get Version-3.10.2 # a specific version
get Version-3.9.3 # ...etc
If you don’t know what to pick, use master
. If you pick a specific version, you’ll get a message from git
about being in a ‘detached HEAD’ state. This is fine, ignore it.
Note: As of 3.10, SuperCollider’s IDE will no longer build on RaspberryPi. This has to do with Qt’s web viewer component. SuperCollider hopes to have a workaround soon, but it isn’t there as of 3.10.2. If you need or want the IDE, run version 3.9. Personally, I the IDE on my main computer to develop my patches, then move the files to the Pi and run them there without the IDE.
Now run:
git submodule update --init --recursive
Get development packages
Make a list of the development packages you need:
devpkgs="cmake libasound2-dev libavahi-client-dev libfftw3-dev libjack-jackd2-dev"
devpkgs+=" libreadline-dev libsamplerate0-dev libsndfile1-dev libudev-dev"
If you are building the ide, add:
devpkgs+=" libqt5sensors5-dev libqt5webkit5-dev libxt-dev"
devpkgs+=" qtpositioning5-dev qttools5-dev-tools"
Install these packages:
sudo apt-get install --no_install_recommends $devpkgs
Run the build
This step can take over an hour:
# you should still be in the supercollider directory
mkdir build
cd build
opts="-DCMAKE_BUILD_TYPE="Release"
opts+=" -DBUILD_TESTING=OFF
opts+=" -DENABLE_TESTSUITE=OFF
opts+=" -DINSTALL_HELP=OFF
opts+=" -DSUPERNOVA=OFF # could set to ON if you want
opts+=" -DNATIVE=ON
opts+=" -DSC_WII=OFF # not needed with 3.10, but doesn't hurt
opts+=" -DSC_IDE=OFF # set to ON if you want the IDE, and 3.9 or earlier
opts+=" -DSC_QT=OFF # set to ON if you want the IDE and/or Qt UI objhects
opts+=" -DSC_ED=OFF
opts+=" -DSC_EL=OFF # set to ON if you use emacs
cmake -L $opts ..
make
In theory you could build with make -j 4
to build four things at once, but the Pi can run out of memory, and this fails. make -j 2
seems to work on mine, but just plain make
is safe, just takes longer.
Install
sudo make install
sudo ldconfig
This will install everything under /usr/local
.
If you want to install your own extensions (class libraries, quarks), they go in one of these two places:
/usr/local/share/SuperCollider/Extensions
/home/pi/.local/share/SuperCollider/Extensions
Symlinks in there to your own directories are fine, and SuperCollider will traverse into them to find your code.
Set up
SuperCollider talks to jackd
, which in turn talks to alsa
. You can let SuperCollider handle starting and stopping jackd
for you, but you need to set it up.
Edit (vi
or emacs
or nano
) the file ~/.jackdrc
to have the following single line:
/usr/bin/jackd -R -P 75 -d alsa -d hw:pisound -r 48000 -n 2 -p 64 -s
Test it
Run:
export JACK_NO_AUDIO_RESERVATION=1 # this is essential, and you could put it in your .bashrc
sclang
You should see messages about it compiling the class library, and then finally the sc3>
prompt. To that, type:
s.boot
You’ll see a lot of status lines print, and near the end ‘SuperCollider 3 server ready.’ Then try:
{ Ringz.ar(EnvGen.ar(Env.perc, doneAction: Done.freeSelf), 105) * 0.3 }.play
Now try something more wonderful (careful, it must be all on one long line):
play{q=SinOsc;a={|x...y|perform(x,\ar,*y)};Splay ar:a.(CombN,c=a.(q,0,a.(Blip,1/f=(1..8),888/a.(q,1/88,0,2,3).ceil*a.(Duty,a.(q,1/8)>0+2*1/8,0,Dseq([8,88,888],inf)))*188),1,8-f/8,8)/8+a.(CombN,a.(GVerb,a.(BPF,8*e=c.mean,88,1/8),88),1,1)+a.(q,88,0,a.(q,0,e)<0/88)}// #SuperCollider