The Living Thing / Notebooks :

Supercollider

Supercollider (downloads link) is the collective noun describing two coupled programming languages oriented toward live interactive music. I used ’em a lot, e.g. for pattern machine,

The default user-facing frontend is a language called sclang, an ageing smalltalk derivative with neat scheduling facilities embedded in some awkward abstractions, and a lot of handmade quirk. The DSP backend is called scsynth. The two talk to one another over a decrepit defunded network protocol from 1999 called opensoundcontrol. scsynth is wonderful. sclang has some wonderful advanced features, but is hamstrung by its ancient and unrefactored early design decisions. It’s an underdeveloped ghetto, kind of a District 9 of software.

It has some hard-to-find features, such as

It has a small but committed community, and doesn’t require extortionate licensing fees as an open-source project. Unfortunately it is purely GPL’d, which makes it difficult to release real software using it or put it on iphones etc.

Having used sclang extensively, I feel qualified to recommend against it; It has fame and regard because it really was the best in the field in 2002; But it’s missing the bulk of the progress since 2002 that mainstream languages have taken for granted. Supercollider’s tasty language features sound great, but they are nearly unusable because of the obscure and buggy nature of the language they are embedded in.

Also, it’s falling gradually apart. Supercollider rootbound by a frozen and confusing chaos of early design decisions that make the sequencing unreliable and inflexible, state-management an irritating hack, and the ecosystem a jungle of different partial workarounds. Modern functional reactive programming has honed a lot of the design patterns here, but that revolution kicked off after supercollider froze.

Perhaps you’d like to use javascript to control scsynth instead? Or something else? There is a whole ecosystem of alternative sequencing languages that interface with the DSP core, because everyone has had more or less the same realisation. Thus we have scsynth front-ends for Haskell, Javascript, Clojure, Ruby, and Python. All of these have different plusses and minus; But they all have access to much deeper ecosystems built around their respective languages. But perhaps you can’t use one of them?

Vanilla sclang notes

In a classic failure of academic publishing, the de facto manual for SC was released as a closed-source, heavily-delayed, pre-obsoleted, very expensive book. There is an effort underway to transate Valle’s alternative manual.

There are lots of bad bits mentioned. Don’t interpret these as complaints; think of them as little public encouragements for me to learn C++ coding and start fixing them. NB: this won’t actually ever happen.

OTOH, why the hell does there exist yet another poorly-maintained programming language, when we have many, many others and some of those even have a maintenance budget? Why not choose your battles by adapting a mainstream language to be better at programming audio? If that sounds too complicated (and it is somewhat complicated) here are some things that you be aware of when using supercollider.

debugging

No step debugger, so you have to debug your complex nests of client and server-side code with print statements. That’s the recommended way, and precisely what the debug method does.

Get ready for hours reverse engineering your code to work out what this time cause the Omni Error:

    ``^^ The preceding error dump is for ERROR: Message 'foo' not understood.
RECEIVER: nil``

Not-really-interactive scope

Used to defining variables in a REPL and then using them later?

Try running these two lines, both at once:

var foo="bar";
foo;

You should get back, as you’d expect, bar. Now, run them one at a time. Result:

• ERROR: Variable 'foo' not defined.
    in file 'selected text'
    line 1 char 3:
    foo•;

You can work around this by using “environments”, and other hacks, that is, creating variables as entries in a hash-table with reasonably compact syntax: give them names prepended with a tilde, as, e.g. ~foo. However, this means that you have completely different syntax and scoping rules in live and library coding. There are two different languages you now have to work with, and neither helps to debug the other particularly much. If, say, you wanted to copy a troublesome method from a class into the interactive document window to step through it and work out where it’s gone wrong (since, as mentioned above, there is no step debugger, this is as good as it gets)… and so the pain develops from a nagging irritation to a skull-grinding cluster headache.

Concurrency hell

esp. server-client concurrency hell.

While supercollider still has the best sequencer, other concurrency problems have been solved by the rest of the world while sclang stagnated.

If you code the way that the help files do things, i.e. small numbers of lines of code, each executed manually, you will end up writing code that looks like it works but explodes the moment you try to increase the speed or parallelism with which it is executed. To do anything at all you need to execute it inside a Routine and use server synchronisation to make sure that nothing arrives out of order. However, in my experience this is still not 100% reliable; the entire thing relies on UDP packets which have no particularly useful guarantees about order of arrival or verification of arrival. However, it’s better than nothing; If you don’t do this, sometimes you will get nice, plain errors. More perniciously, sometimes, with with patches involving complicated wiring such as Instr and FFTs and such, you put yourself at risk of having things wired together entirely incorrectly, and having hard-to-trace examples of Bus objects full of crosstalk and garbage.

IO

OSC and MIDI are handled by an elegant evented asynchronous callback system after the latest modern style. Could be better but feels fairly natural, and you can subclass away the rough edges. However for all other IO (file, socket, other network protocols, serial, whatever), it’s blocking access. So if you wish to talk other, more modern protocols, you are reasonably fucked, and for that matter, your elegant OSC/MIDI system is caught in the crossfire. In practice you end up running another instance to relay pipe contents over OSC.