SponcSupercollider

Version 1 (admin, 20/03/2012 14:46)

1 1 admin
h1. Sponc Supercollider
2 1 admin
3 1 admin
{{>toc}}
4 1 admin
5 1 admin
h1. Forewords
6 1 admin
7 1 admin
* For ubuntu, there is a launchpad ppa available: https://launchpad.net/~supercollider/+archive/ppa
8 1 admin
* This installation guide has been applied and tested specifically for SuperCollider 3.2 and 3.3 on Ubuntu 8.04.
9 1 admin
* The packaged version of SuperCollider for Ubuntu seemed to have unpredictable problems on handling jack outputs.
10 1 admin
* 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. 
11 1 admin
12 1 admin
h1. Prerequisites
13 1 admin
14 1 admin
For Ubuntu 8.04, copy&paste:
15 1 admin
16 1 admin
<pre>
17 1 admin
$ sudo apt-get install gcc g++ scons libsndfile1-dev libfftw3-dev \
18 1 admin
libjack-dev libasound2-dev libavahi-client-dev pkg-config emacs jackd
19 1 admin
</pre>
20 1 admin
21 1 admin
Recommended package:
22 1 admin
23 1 admin
<pre>
24 1 admin
$ sudo apt-get install qjackctl
25 1 admin
</pre>
26 1 admin
27 1 admin
h1. Download and compile sources
28 1 admin
29 1 admin
Download the sources here: http://supercollider.sourceforge.net/downloads/
30 1 admin
31 1 admin
Unpack and build:
32 1 admin
33 1 admin
<pre>
34 1 admin
$ cd /path/to/tmp
35 1 admin
$ scons build
36 1 admin
</pre>
37 1 admin
38 1 admin
You should take a look at the build summary, that should be something like this:
39 1 admin
40 1 admin
<pre>
41 1 admin
------------------------------------------------------------------------
42 1 admin
 ALTIVEC:                 no
43 1 admin
 AUDIOAPI:                Jack
44 1 admin
 MIDIAPI:                 ALSA
45 1 admin
 DEBUG:                   no
46 1 admin
 DEVELOPMENT:             no
47 1 admin
 LANG:                    yes
48 1 admin
 LID:                     yes
49 1 admin
 WII:                     no
50 1 admin
 PREFIX:                  /usr/local
51 1 admin
 RENDEZVOUS:              yes
52 1 admin
 SCEL:                    yes
53 1 admin
 SSE:                     yes
54 1 admin
 CROSSCOMPILE:            no
55 1 admin
 TERMINAL_CLIENT:         yes
56 1 admin
 X11:                     yes
57 1 admin
------------------------------------------------------------------------
58 1 admin
</pre>
59 1 admin
60 1 admin
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:
61 1 admin
62 1 admin
<pre>
63 1 admin
$ sudo mkdir /opt/sc
64 1 admin
$ scons PREFIX=/opt/sc
65 1 admin
</pre>
66 1 admin
67 1 admin
At the end of the compilation process, an _install_ can be issued:
68 1 admin
69 1 admin
<pre>
70 1 admin
$ sudo scons install
71 1 admin
</pre>
72 1 admin
73 1 admin
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.
74 1 admin
75 1 admin
h1. Testing
76 1 admin
77 1 admin
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:
78 1 admin
79 1 admin
<pre>
80 1 admin
$ scsynth -u 57110 -b 1026
81 1 admin
</pre>
82 1 admin
83 1 admin
You should simply notice this line:
84 1 admin
85 1 admin
<pre>
86 1 admin
SuperCollider 3 server ready..
87 1 admin
</pre>
88 1 admin
89 1 admin
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:
90 1 admin
91 1 admin
<pre>
92 1 admin
$ jack_lsp -c
93 1 admin
system:capture_1
94 1 admin
system:capture_2
95 1 admin
system:playback_1
96 1 admin
system:playback_2
97 1 admin
system:playback_3
98 1 admin
system:playback_4
99 1 admin
system:playback_5
100 1 admin
system:playback_6
101 1 admin
system:playback_7
102 1 admin
system:playback_8
103 1 admin
SuperCollider:in_1
104 1 admin
SuperCollider:in_2
105 1 admin
SuperCollider:in_3
106 1 admin
SuperCollider:in_4
107 1 admin
SuperCollider:in_5
108 1 admin
SuperCollider:in_6
109 1 admin
SuperCollider:in_7
110 1 admin
SuperCollider:in_8
111 1 admin
SuperCollider:out_1
112 1 admin
SuperCollider:out_2
113 1 admin
SuperCollider:out_3
114 1 admin
SuperCollider:out_4
115 1 admin
SuperCollider:out_5
116 1 admin
SuperCollider:out_6
117 1 admin
SuperCollider:out_7
118 1 admin
SuperCollider:out_8
119 1 admin
</pre>
120 1 admin
121 1 admin
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.
122 1 admin
123 1 admin
There is also a neater way to make connection by default, using environmental variables:
124 1 admin
125 1 admin
<pre>
126 1 admin
$ export SC_JACK_DEFAULT_OUTPUTS="alsa_pcm:playback_1,alsa_pcm:playback_2"
127 1 admin
</pre>
128 1 admin
129 1 admin
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.
130 1 admin
131 1 admin
Starting up again scsynth should give this message:
132 1 admin
133 1 admin
<pre>
134 1 admin
JackDriver: client name is 'SuperCollider'
135 1 admin
JackDriver: max output latency 23.2 ms
136 1 admin
JackDriver: connected  SuperCollider:out_1 to alsa_pcm:playback_1
137 1 admin
JackDriver: max output latency 23.2 ms
138 1 admin
JackDriver: connected  SuperCollider:out_2 to alsa_pcm:playback_2
139 1 admin
SuperCollider 3 server ready..
140 1 admin
</pre>
141 1 admin
142 1 admin
And jack_lsp:
143 1 admin
144 1 admin
<pre>
145 1 admin
---SNIP---
146 1 admin
SuperCollider:out_1
147 1 admin
   system:playback_1
148 1 admin
SuperCollider:out_2
149 1 admin
   system:playback_2
150 1 admin
---SNIP---
151 1 admin
</pre>
152 1 admin
153 1 admin
h1. Emacs+SClang test
154 1 admin
155 1 admin
If SCEL has been selected among SuperCollider installation profile, just paste this snippet on @~/.emacs@:
156 1 admin
157 1 admin
<pre>
158 1 admin
(require 'sclang)
159 1 admin
</pre>
160 1 admin
161 1 admin
Then launch emacs with:
162 1 admin
163 1 admin
<pre>
164 1 admin
$ emacs -sclang
165 1 admin
</pre>
166 1 admin
167 1 admin
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
168 1 admin
169 1 admin
h1. More tests
170 1 admin
171 1 admin
Jack utils offers also an interesting tool which is called scope:
172 1 admin
173 1 admin
<pre>
174 1 admin
$ jack.scope
175 1 admin
</pre>
176 1 admin
177 1 admin
Inputs of the scope must be connected manually. Use qjackctl or jack_connect to do that, once scsynth is up and running.
178 1 admin
179 1 admin
h1. Avoid Jack
180 1 admin
181 1 admin
If you need for some reason to avoid Jack API, it's possible to use Portaudio API:
182 1 admin
183 1 admin
<pre>
184 1 admin
$ sudo apt-get install portaudio19-dev
185 1 admin
$ scons AUDIOAPI=portaudio build
186 1 admin
</pre>
187 1 admin
188 1 admin
For SuperCollider 3.2, whenever this command ends up with this error:
189 1 admin
190 1 admin
<pre>
191 1 admin
Source/server/SC_CoreAudio.cpp: In function 'int64 GetCurrentOSCTime()':
192 1 admin
Source/server/SC_CoreAudio.cpp:140: error: 'gettimeofday' was not declared in this scope
193 1 admin
</pre>
194 1 admin
195 1 admin
apply the following patch to the source tree:
196 1 admin
197 1 admin
<pre>
198 1 admin
--- Source/server/SC_CoreAudio.cpp	2008-02-19 23:47:22.000000000 +0100
199 1 admin
+++ Source/server/SC_CoreAudio.cpp	2008-08-19 11:07:10.000000000 +0200
200 1 admin
@@ -29,6 +29,7 @@
201 1 admin
 #include "SC_Lib_Cintf.h"
202 1 admin
 #include <stdlib.h>
203 1 admin
 #include <pthread.h>
204 1 admin
+#include <sys/time.h>
205 1 admin
  
206 1 admin
 #ifdef SC_WIN32
207 1 admin
 #include "SC_Win32Utils.h"
208 1 admin
@@ -1955,4 +1956,4 @@
209 1 admin
 {
210 1 admin
 }
211 1 admin
  
212 1 admin
-#endif // SC_AUDIO_API_INNERSC_VST
213 1 admin
\ No newline at end of file
214 1 admin
+#endif // SC_AUDIO_API_INNERSC_VST
215 1 admin
</pre>
216 1 admin
217 1 admin
If you need to know how to do that, simply change in the Supercollider-Source directory and:
218 1 admin
219 1 admin
<pre>
220 1 admin
$ patch -p0
221 1 admin
</pre>
222 1 admin
223 1 admin
Pasting the contents of the proposed patch, then run again the build.
224 1 admin
225 1 admin
h1. Final notes
226 1 admin
227 1 admin
* One common pitfall is when jack applications are executed with different users (e.g.: launching scsynth or emacs using sudo). So be aware to be homogeneous. If you need realtime priority under ubuntu, use limits.conf (more info https://help.ubuntu.com/community/UbuntuStudioPreparation here and https://help.ubuntu.com/community/UbuntuStudioPreparation here
228 1 admin
* SuperCollider can get realtime scheduling priority only with super user grants