Sponc Supercollider

Forewords

  • For ubuntu, there is a launchpad ppa available: https://launchpad.net/~supercollider/+archive/ppa
  • This installation guide has been applied and tested specifically for SuperCollider 3.2 and 3.3 on Ubuntu 8.04.
  • The packaged version of SuperCollider for Ubuntu seemed to have unpredictable problems on handling jack outputs.
  • Jack framework is probably the best investment over time as it has very flexible methods to change audio topology (mix, split, readdressing), although it seems not so easy to avoid xruns that happen quite often, even with high, RT prio scheduling (and, at least, on ubuntu 8.04 stock + rt kernel). Portaudio in these situations works out of the box and with no tweaking.

Prerequisites

For Ubuntu 8.04, copy&paste:

$ sudo apt-get install gcc g++ scons libsndfile1-dev libfftw3-dev \
libjack-dev libasound2-dev libavahi-client-dev pkg-config emacs jackd

Recommended package:

$ sudo apt-get install qjackctl

Download and compile sources

Download the sources here: http://supercollider.sourceforge.net/downloads/

Unpack and build:

$ cd /path/to/tmp
$ scons build

You should take a look at the build summary, that should be something like this:

------------------------------------------------------------------------
 ALTIVEC:                 no
 AUDIOAPI:                Jack
 MIDIAPI:                 ALSA
 DEBUG:                   no
 DEVELOPMENT:             no
 LANG:                    yes
 LID:                     yes
 WII:                     no
 PREFIX:                  /usr/local
 RENDEZVOUS:              yes
 SCEL:                    yes
 SSE:                     yes
 CROSSCOMPILE:            no
 TERMINAL_CLIENT:         yes
 X11:                     yes
------------------------------------------------------------------------

Relevant points are: AUDIOAPI, SCEL (if you want to use Emacs+SCLang). Be sure that AUDIOAPI is "Jack". If you prefer an /opt installation (untested) instead of a /usr/local one, type:

$ sudo mkdir /opt/sc
$ scons PREFIX=/opt/sc

At the end of the compilation process, an install can be issued:

$ sudo scons install

Note for SC 3.3: for those who hate Emacs and its mindmelter keystrokes, there is a new addition called SCED, which is a plugin for GEdit.

Testing

Our interest is on scsynth, located in /usr/local/bin/scsynth (or /opt/sc/bin/scsynth). We're going to test if it boots correctly:

$ scsynth -u 57110 -b 1026

You should simply notice this line:

SuperCollider 3 server ready..

With a pristine situation, Supercollider won't ask for any jack connection. This can be seen issuing a jack_lsp command, that should report something like this:

$ jack_lsp -c
system:capture_1
system:capture_2
system:playback_1
system:playback_2
system:playback_3
system:playback_4
system:playback_5
system:playback_6
system:playback_7
system:playback_8
SuperCollider:in_1
SuperCollider:in_2
SuperCollider:in_3
SuperCollider:in_4
SuperCollider:in_5
SuperCollider:in_6
SuperCollider:in_7
SuperCollider:in_8
SuperCollider:out_1
SuperCollider:out_2
SuperCollider:out_3
SuperCollider:out_4
SuperCollider:out_5
SuperCollider:out_6
SuperCollider:out_7
SuperCollider:out_8

The eight outputs of SuperCollider are not connected to any system's PCM device. This can be done using jack_connect or a tool called qjackctl (Ubuntu package: qjackctl). Each time scsynth is closed, connection topology is lost.

There is also a neater way to make connection by default, using environmental variables:

$ export SC_JACK_DEFAULT_OUTPUTS="alsa_pcm:playback_1,alsa_pcm:playback_2" 

This one connects the first two outputs of SuperCollider to the first two system's PCM devices. Each comma gets a new SuperCollider output, sequentially, basing on the availability of the audio subsystem.

Starting up again scsynth should give this message:

JackDriver: client name is 'SuperCollider'
JackDriver: max output latency 23.2 ms
JackDriver: connected  SuperCollider:out_1 to alsa_pcm:playback_1
JackDriver: max output latency 23.2 ms
JackDriver: connected  SuperCollider:out_2 to alsa_pcm:playback_2
SuperCollider 3 server ready..

And jack_lsp:

---SNIP---
SuperCollider:out_1
   system:playback_1
SuperCollider:out_2
   system:playback_2
---SNIP---

Emacs+SClang test

If SCEL has been selected among SuperCollider installation profile, just paste this snippet on ~/.emacs:

(require 'sclang)

Then launch emacs with:

$ emacs -sclang

Be sure to have an SCLang menu on Emacs menu bar. Remember that you can get out of Emacs mess using Ctrl-X Ctrl-C, that lines are evaluated with Ctrl-C Ctrl-C and blocks with Ctrl-C Ctrl-X

More tests

Jack utils offers also an interesting tool which is called scope:

$ jack.scope

Inputs of the scope must be connected manually. Use qjackctl or jack_connect to do that, once scsynth is up and running.

Avoid Jack

If you need for some reason to avoid Jack API, it's possible to use Portaudio API:

$ sudo apt-get install portaudio19-dev
$ scons AUDIOAPI=portaudio build

For SuperCollider 3.2, whenever this command ends up with this error:

Source/server/SC_CoreAudio.cpp: In function 'int64 GetCurrentOSCTime()':
Source/server/SC_CoreAudio.cpp:140: error: 'gettimeofday' was not declared in this scope

apply the following patch to the source tree:

--- Source/server/SC_CoreAudio.cpp    2008-02-19 23:47:22.000000000 +0100
+++ Source/server/SC_CoreAudio.cpp    2008-08-19 11:07:10.000000000 +0200
@@ -29,6 +29,7 @@
 #include "SC_Lib_Cintf.h" 
 #include <stdlib.h>
 #include <pthread.h>
+#include <sys/time.h>

 #ifdef SC_WIN32
 #include "SC_Win32Utils.h" 
@@ -1955,4 +1956,4 @@
 {
 }

-#endif // SC_AUDIO_API_INNERSC_VST
\ No newline at end of file
+#endif // SC_AUDIO_API_INNERSC_VST

If you need to know how to do that, simply change in the Supercollider-Source directory and:

$ patch -p0

Pasting the contents of the proposed patch, then run again the build.

Final notes