Table of Contents

SuperCollider constitutes of three parts: an IDE, a language (sclang), the server.

This section records along the way I went through the tutorial and documentations of SuperCollider.

1 The IDE

I found the IDE pretty easy to use, with color highlight and auto completion.

At one line, CMD-enter to execute. In the following sections, "run the command" means run a line of code using this way.

During playing of music, CMD-. to stop playing. When selecting some class, e.g. SinOsc, CMD-d will open the reference if one exists.

2 Concepts

unit generator
or UGen for shot.
sine wave oscillator.
SuperCollider calculates audio in groups of samples, called blocks.
audio rate
ar Audio rate means that the UGen will calculate a value for each sample in the block.
control rate
kr calculate a single value for each block of samples.

3 Playing sound

{[, 0, 0.2),, 0, 0.2)]}.play;

In the SinOsc function, the three parameters are

Hertz, or cycles per second (cps)
Phase refers to where it will start in the cycle of its waveform. Value ranges from (0,2*pi)
multiple the signal
addition to the signal

The polymorphism in SuperCollider is pass one object as one parameter to create another object.

{ var ampOsc;
  ampOsc =, 1.5pi, 0.5, 0.5); // this is control rate // mul 0.5, add 0.5 results in (0,1), 0, ampOsc); // the above (0,1) object is used as "mul" in this one.

This defines a anonymous function, and call .play method on a function. This indicates the function: 1) evaluate 2) play the result on the server

In addition to .play, such function also has .plot, which shows the phase graph. .scope shows the dynamic counterpart of .plot, which also starts to play it, of course.

3.0.1 Multiple Channels

Using arrays, you can define the left and right channels. See array section in grammar.

4 sclang

4.0.1 Hello World

"hello world".postln;

4.0.2 Grammar

semi-colon is the separator.

Statements can be grouped to run at the same time.


4.0.3 the server

The server must be started to play any sound. To start the server: s.boot, to stop it: s.quit. Note that the object s is reserved and means the server.

4.0.4 built-in object

2.0.rand; // generate random value

4.0.5 Function

Function is for reuse of a code. A function is an object.

f = { "Function evaluated".postln; }; // define a function // by the way this is comment
f; // does not evaluate, seems to define one more time
f.value; // will evaluate

f; will not evaluate it, but f.value does.

f = { arg a, b=3; // argument, with default value
  a - b;
f.value(5, 3); // evaluate with parameters
f.value(b:3, a:5); // different order by "keyword arguments"

g = {|a,b| a+b;} // verticle line is the same as using "arg" keyword

4.0.6 Variables

There're two places to declare a variable. Function variable

Function can have variables. Does it mean only functions can have variables?

f = { arg a, b;
// the variables must be defined right after the argument componnent
  var firstResult, finalResult; // declara variables, using keyword "var"
  firstResult = a + b;
  finalResult = firstResult * 2;
f.value(2, 3); // this will return (2 + 3) * 2 = 10
) Block variable

Variables can also be declared at the top of any block.

var myFunc; // a custom function name must be declared, before assignment
myFunc = { |input| input.postln; }; // assignment
myFunc.value("foo"); // arg is a String
myFunc; // error, out of scope

The a to z are predefined in global scope. E.g. f for a function, and s for a server. You can use them without actually declare them.

4.0.7 Array

a = ["foo", "bar"];;;

This enables multiple channel playing:

{ [, 0, 0.2),, 0, 0.2)] }.play;

This defines left and right channel. It can me more channels, but I don't know what it means to be three channels? …

4.0.8 Class

Classes starts with uppercase letter. SinOsc PinkNoise Pan2 Saw Mix