Music Software: SuperCollider

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

3 Likes

Thanks for this in depth guide. I am running Patchbox OS on a 3b+ with Pisound, with the installed SC package starting complaint free, the server boots and JackDriver shows as connected in the post window and in Patchage. When I try to run the first test snippet I get this error.

illegal input string '�' 
   in interpreted text line 1 char 20
code 226
  in interpreted text line 1 char 20
ERROR: syntax error, unexpected BADTOKEN
  in interpreted text
  line 1 char 20:

  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).ceila.(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,8e=c.mean,88,1/8),88),1,1)+a.(q,88,0,a.(q,0,e)<0
                     ^
-----------------------------------
ERROR: Command line parse failed
-> nil

Also, in the Fieldsteel tutorials there is a nice Help window I can’t figure out how to get. Is that available on this platform?

Any help on either topic is much appreciated.

Looks to me like the parser is seeing the"…" as a single character (elipsis) in unicode (and does not recognize it, so you get the question mark thing for a missing unicode glyph in the original error message) - I think this needs to be three separate “.” characters but this is just a guess. Probably a text editor (or terminal?) somewhere is translating to unicode (or UTF) but that is even more of a guess.

hope this helps,
John

2 Likes

Yes, it does look like ‘…’ was converted to a single character, causing the issue. I’ll edit the original post to use code blocks for the examples. :slight_smile:

1 Like

I think most of my problem is that I missed that SCIDE is not supported on Pi past 3.10. bummer.

Is there an official announcement somewhere about the dropped support?

Did you fix the ‘…’ symbol in your code?

see the original post:

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.

i did fix both those ellipses occurrences but was still getting an error. could have been cause I was on an unsupported platform…? besides not getting the window, if I leave scide running and walk away the system hangs.

What error did you get after fixing the …?

I had to work around some issues but made it with the help of the official guide and this one for headless:

cmake -DCMAKE_BUILD_TYPE=Release -DSUPERNOVA=OFF -DSC_ED=OFF -DSC_EL=OFF -DSC_VIM=ON -DNATIVE=ON -DSC_IDE=OFF -DNO_X11=ON -DSC_QT=OFF -DSC_WII=OFF -DBUILD_TESTING=OFF -DENABLE_TESTSUITE=OFF -DINSTALL_HELP=OFF -DNATIVE=ON

cmake --build . --config Release --target all -- -j3 # use -j3 flag only on RPi3 or newer
sudo cmake --build . --config Release --target install
sudo ldconfig

start supercollider with sclang afterwards – sooo cool :slight_smile:

1 Like

Ar these commands to be used instead of these:

?

Anymore changes required in the guide to bring it up to date?