SuperCollider: A journey into the unknown
This is an account of my supercollider learning process. I already know something about the behavior of realtime audio engines, have tried writing a couple, and having failed. The goal of this guide is to help you learn basic supercollider concepts faster than I did.
Supercollider has two parts: a server: scsynth, and a client: sclang. sclang is a normal (OSC?) client like any other application that you may write to use scsynth as a dsp engine. scsynth is wicked fast. anything regarding synthdefs and other language constructs has everything to do with sclang, and very little to do with scsynth.
Sounds come from UGens. You can define new ones by defining a SynthDef? in yoursynth.sc. This file is compiled (somehow?) and put into a ./synthdef folder where it will be loaded the next time you run scsynth, the supercollider engine.
Notes are played by sending an OSC bundle with a synth and a precises execution time in the future. At first glance it seems that you instantiate a synthdef then play notes on it, but actually you instantiate the synth once for every note. Supercollider is really fast, so you don't have to worry about the overhead of creating a synth. The trick, then, is to write your synthdefs with variable parameters so you can change them for each note. In my python code a synth is just a dictionary of arguments passed to a play() method.
Because we have to send messages for notes in the future, we have to get our sequencer to scan for notes within the control window, usually around 1 or less seconds in the future. This creates a latency using the same principle as an audio hardware interrupt.
The docs are very confusing on this topic. In fact, I still don't get it. When one reads the Order-of-execution help file, it appears that order of execution determins a signal's flow from one node to another. This is false, because order of execution has nothing to do with signal routing and patch cables. Busses and only busses move audio between nodes. if a consumer node with an In bus is executed before a producer with a corresponding Out bus, the producer will receive silence. So, when trying to route signals from ugens to effects use busses, and then in a seperate brain cycle, make sure that the ugen synths are near the head and filters are near the tail.