s = Server.local;
s.boot;
s.quit;

(
SynthDef("test", { arg freq=220;
var sound;
sound = SinOsc.ar(freq);
Out.ar(0, [sound, sound]);
}).writeDefFile;
s.sendSynthDef("test");
)

z = Synth("test");
z.set("freq", 555);
z.free;

// A look at the language in more depth:
----------------------------------
SynthDefs - these define the architecture of a synth.
Format:
SynthDef(name, ugen function)

Each SynthDef is always referred to by its name, so it must always be unique.

The ugen function contains a collection of ugens. When a SynthDef is compiled, all functions are evaluated and cannot be changed - the architecture is fixed. For example, if you have some conditional code inside your SynthDef ( if arg1=arg2 do this else do that) it will be evaluated at compilation time only. In the example above, it will be evaluated using the initial values of arg1 and arg2. If change the values of these arguments after compilation, it will not be re-evaluated.

Instance methods:
writeDefFile - compiles the SynthDef and writes it as a file called name.scsyndef in your SynthDefs folder. Alternatively you can pass another location as an argument.
SynthDef("blah",{blah blah blah}).writeDefFile(/path/to/another/folder);

load - also compiles the SynthDef and writes a file, then tells the server to load it. 
SynthDef("blah",{blah blah blah}).load(s);

send - compiles the SynthDef and sends it to the server without writing a file.
SynthDef("blah",{blah blah blah}).send(s);

play - compiles the SynthDef, writes a file, sends it to the server, creates one synth using this definition. By default the synth is added to the head of the server. You can specify the target (i.e. which server you want to send it to,), any argument values you want to use and an alternative add action (e.g. add it to the tail of the server instead).
SynthDef("blah",{blah blah blah}).play(s, [\arg1name, arg1value, \arg2name, arg2value]);

What's the difference?

SynthDef compilation is asynchronous - you have no way of knowing when the server has finished compiling and is ready to create another synth. The compilation is quite an intensive task and if you compile a lot at the same time, you will get cpu spikes. If they are compiled and sent to the server already, then any future synths using these defs will have less of an effect on cpu usage at creation time. 

Using send instead of load or writeDefFile means that you need to compile the SynthDef every time you boot the server. The other two methods mean that you can send the existing scsyndef file from your synthdefs folder instead.

----------------------------------------------------

What does this "instance method" thing mean?

An instance method is an operation which can be performed on a particular object or class. Different objects/classes will have different instance methods.

The Server object has got the instance methods boot and quit amongst others. You have probably worked out by now how an instance method is called - you pass it back to the object/class using a .
e.g:
s = Server.local; // the local method returns an instance of the local server
s.boot;	// the boot method will start the server stored as the environment variable s;
s.quit; // the quit method will stop the server etc. etc. etc.
Other useful instance methods for the Server object include reboot, freeAll, status, sendSynthDef.

-----------------------------------------------------

Functions

Functions in SuperCollider are defined using {}. They can have arguments which can then have values passed on to them at evaluation. Functions are evaluated using the value method.

a = { arg num1, num2; 
	num1 + num2;
	 };
a.value(1,1);

Maths operations can be performed on functions themselves by creating another function

b = { arg num1, num2;
	num1 - num2;
	 };
b.value(2,1);

c = {arg num1,num2,num3,num4;
	a.value(num1,num2) + b.value(num3,num4);
	 };
c.value(4,2,5,4);

Other useful function methods:

dup(n) - returns an array containing n evaluations of the function

d = { 10.rand; }.dup(5);

defer(n) - defers the evaluation of the function by n seconds

{ "5 seconds later...".postln; }.defer(5);

---------------------------------------------------------

Literals (see help file - I'm just putting this here so I can open it!)

---------------------------------------------------------

Conditional programming

This is implemented using if. You pass an expression to be tested, a function to be evaluated if it returns true, and an optional function to be evaluated if it returns false.

Format:

if (expression, {true function}, {false function});

a = { arg num = 1;
if ( num < 5, { "Your number is less than five"; }, 
				{ "Your number is greater than five"; });
		};

a.value(3);
a.value(7);
a.value(5); // ummm, no it's not!

a = { arg num = 1;
if ( num < 5, { "Your number is less than five"; }, 
				{ if ( num == 5, {"Your number is equal to five"; },
									{"Your number is greater than five";});
				});
		};
		
a.value(3);
a.value(7);
a.value(5); // That's better!

--------------------------------------------------------

Synths

A synth is a sound producing unit. As we have seen, its architecture is defined by a SynthDef. Every time a synth is created, it is assigned an individual node id on the server. The Synth class can be used to create and control synths.

Format: Synth("defname", [argument array], target, add action);

x = Synth("myDefName"); // will create a new synth using the SynthDef "myDefName"

You can also supply an array of argument values when creating a synth in this way. They take the form [arg1name, arg1value, arg2name, arg2value, ... argNname, argNvalue]. The argument names can be expressed as strings or symbols (i.e. "freq" or \freq )

x = Synth("myDefName", ["argument1", 2, "argument2", 438]);

The target is a reference to the server or group you want to create it on. It defaults to the local server.

The add action lets you specify in what order it gets placed on the server/group. Options are:

\addToHead - adds it to the head of the group specified by target
\addToTail - adds it to the tail of the group specified by target
\addAfter - adds it after the group or synth specified by target
\addBefore - adds it before the group or synth specified by target
\addReplace - replaces target and takes its place in the node order

---------------------------------------------------------------------

Order of execution

Why is this so important?

SuperCollider processes synths in the order they appear on the server, starting from the head and moving to the tail. This, therefore, determines the order in which their output is generated every cycle. If you have one synth feeding audio or control information into another, then it is important that it appears before the synth receiving this information.

*** The order in which you send things to the server does not necessarily equal the order they will appear in! ***

Essentially, you need to make sure that you follow the rule source --> effect

This is where the add actions mentioned above come into play. You can specify exactly where a synth will appear.

There are shortcut methods for the Synth class which will do the same thing as using the above add actions:

.tail - same as \addToTail
.head - same as \addToHead
.after - same as \addAfter
.before - same as \addBefore
.replace - same as \replace

If you use these, then it takes the form

Synth.method(target, "defname", [arguments]);

Exactly how it copes with the target depends on the method and what type of target you specify. You can see a detailed description of these in the Order-of-execution help file.

----------------------------------------

Changing order of execution while a synth is running

There are some additional methods which allow you to change the order of synths while they are running. These are:

.moveAfter(target);
.moveBefore(target);
.moveToHead(target);
.moveToTail(target);

e.g.

x = Synth.head(s, "mydef");
y = Synth.after(x, "mydef2");
z = Synth.tail(s, "mydef3");

x.moveAfter(y);
y.moveToTail(s);

----------------------------------------

Other useful Synth methods

As well as the add action shortcuts, there are a number of other useful instance methods for the Synth class.

.newPaused("defname", [args], target, addaction); - creates a new synth and pauses it.
.run - will run a paused synth
.run(false) - will pause it again
.free - will stop the synth and free the node it was using
.release(time) - will fade out the synth over time number of seconds if it contains a sustaining envelope
.set(arg1name, arg1value, arg2name, arg2value ... argNname, argNvalue)
This allows you to send new values to arguments while a synth is running. The argument name can be represented as a string or a symbol.
.query - retrieves information about the synth - what node it uses, its place on the server

----------------------------------------

Checking order of synths

There is a useful utility menu accessible by executing the following

Crucial.menu;

The Query all Nodes will print out the node ids and order of all currently running synths