Posted: 02 April 2012
I'm on a quest to generate some interesting audio for my game, and came across SuperCollider which describes itself as an "environment and programming language for real time audio synthesis and algorithmic composition".
In going through one of the tutorials I discovered that SuperCollider has a quirky little language for generating audio.
The system has pre-defined all the single-letter lowercase letters as
variables (generally to declare a variable you must say var myVariable
).
Some, like the variable s
, even have default values (the default sound
server in this case).
The syntax for declaring arguments to a function is to
use the keyword arg
and the list of parameters (which can have default
values) as the very first statement of the function body. Additionally,
there is a more math-y syntax to declare parameters by enclosing the
parameters in |
, resulting in something like:
f = { |a,b,c| a + b + c; }
This assigns the function (in the { }
) to f
. It takes three
parameters. The last statement of the function is implicitly the return
value, so evaluating this function will return the sum of the three
parameters.
Another non-traditional shortcut in this language is this syntax: 1.5pi
.
Since radians are frequently used in the generators, being able to
efficiently multiply by π is handy. So, you can just suffix a number
with pi
to get that product.
The looping construct also looks unusual to me. SuperCollider supports
N.do({...})
as in:
16.do({ "Hi".postln; });
which would print "Hi" 16 times. This is not restricted to literals, either:
var x = 12; x.do({ "Huh".postln; });
Overall, SuperCollider is oriented more to music composition than sound effects (especially for an audio neophyte like myself), but the tutorial is good and the programming language has some interesting concepts in it.
Anyone with a stronger grasp of audio fundamentals interested in computer-generated audio would probably find SuperCollider interesting.