SC02 Basics

SuperCollider - Tutorial 02 (Basics continued)

Originally authored by David Cottle

Needed

Start Applications >> Audio & Video >> JACK Control
If top left Start button is Green select it
This needs to start with no errors
Start Applications >> Accessories >> Text Editor (Gedit)
Start Tools >> SuperCollider mode
Start from SuperCollider menu >> Start Server
Monitor the lower Text Editor (Gedit) display for errors

Term Definitions used in this Tutorial

postln = Print or post message
SinOsc = Sine Oscillator
RLPF = Reasonant Low Pass Filter
Saw = Saw Tooth Oscillator
LFNoise1 = Low Frequency Noise
play = Play sound to Audio O/P
*ar(bus, channelsArray) - write a signal to an audio bus.
*kr(bus, channelsArray) - write a signal to a control bus.
mul = Multiples
add = adding something
SynthDef = Synthesizer Definition
LFSaw = Low Frequency Saw Wave
RLPF = Resonant Low Pass Filter
Out = write a signal to a bus

This Tutorial

Basic's 02 is still an introductory level tutorial for SuperCollider, in this tutorial we aim to look at, and produce simple sounds of tones using similar principals to that already discussed in the previous tutorial the SinOsc (Sine Oscillator) LFNoise (Low Frequency Noise) command amongst some and others that may be new to you.

Please use this code into your Text Editor as a blank template

( // Move edit cursor and press CTRL+E here to run



)

Most if not all the examples shown in this tutorial page actually provide content that is similar if not the same output albeit in slightly different way. Each example can be played on it's own or layered one on top of the other by playing each simultaneously via your Text editor. To achieve this place each code on a separate untitled Text Editor page initiate each one in turn by moving your cursor just after the beginning opening bracket and selecting Control + E for each instance of code.

( // Move edit cursor and press CTRL+E here to run
{ SinOsc.ar(LFNoise0.ar(10, 400, 800), 0, 0.3) }.play;
)

The author of this code David Cottle has suggested the "(s)" plays some significance in his original code you can infer from this that the code has indeed been modified. With SuperCollider installed on Ubuntu the deleted "(s)" has been verified as having no discernible effect when the "(s)" is appended or not, this dependence may only be required when using Mac's.

( // Move edit cursor and press CTRL+E here to run
// Same thing, but assign the Synth object returned to a variable.
a = { SinOsc.ar(LFNoise0.ar(10, 400, 800), 0, 0.3) }.play;
// Press ESC to end
)

Ok what might be happening here, with my limited knowledge I suggest we have an example of a compound statement or Synth object being assigned to the "a" variable, and that in fact it is "a" that holds the string of the code assigned to it, so in other words you are playing the contents of variable "a". The code could have been rewritten thus:-

a = { SinOsc.ar(LFNoise0.ar(10, 400, 800), 0, 0.3) };
a.play;

The above code plays exactly the same as the code preceding it, by all means try it yourself please add the code to the suggested template.

The function { SinOsc... } is being wrapped in a SynthDef. A SynthDef is a fixed arrangement of unit generators that can be reused at will. The above (considered a shortcut syntax in sc3, generally used only for testing) creates a SynthDef behind the scenes, sends it to the server, and plays it. If you write your own SynthDefs explicitly, you have more control over how they're built and used.

It can be quite difficult to see what is going on let alone listen, so we suggest you install Vu Bridge (if not already installed) as this will display the load placed on each channel (Left and Right speaker) the above codes clearly display when played, an attachment for the left channel only. If you repeat an example by David Cottle from the previous page you will notice both channels play with not much difference in code. We suggest you experiment with this and find out why this should be go on it is fun!.

Load just one of the code blocks below and run you will get no audible output, place both code blocks on separate entries within Text Editor (Gedit) then play both code blocks.

( // Move edit cursor and press CTRL+E here to run
SynthDef.new("ch2-ex1", {
Out.ar(0, // an Out ugen is needed to send the signal to a bus
// bus 0 is the hardware out, left channel
SinOsc.ar( // a sine wave oscillator
LFNoise0.ar(10, 400, 800), // randomly choose a frequency every 0.1 sec
0, // phase: constant 0
0.3 // amplitude: constant 0.3
)
)
}).send(s);
a = Synth.new("ch2-ex1", target: s);
a.play(s);
// Press ESC to end
)

When you say a = Synth.new("ch2-ex1", target: s), the language constructs the OSC message [\s_new, "ch2-ex1", 1000, 0, 0] and sends it to the server. The synth ID may be different.

The synth object assigned to a is a language-side placeholder representing the synth on the server. Saying a.free builds the message [\n_free, 1000] and sends to the server.

When you use Synth, Group, Bus, Buffer objects etc., they build OSC messages internally to communicate with the server. This is important to understand how these objects work. Unlike sc2, an sc3 Synth object does no sound processing on its own. It is merely a proxy to talk to server-side synths more conveniently from the language.

( // Move edit cursor and press CTRL+E here to run
SynthDef.new("ch2-ex2", {
Out.ar(0,
RLPF.ar( // Resonant Low-Pass Filter
LFSaw.ar([8, 12], 0.2), // non-band-limited sowtooth for filter source
LFNoise1.ar([2, 3].choose, 1500, 1600), // choose filter cutoff randomly
0.05 // resonance quotient (low number = high resonance)
)
)
}).send(s);
a = Synth.new("ch2-ex2", target: s);
a.play(s);
// Press ESC to end
)

We hope this tutorial will help you get started with SuperCollider. Make sure you also stop by the SuperCollider website and the wiki for more tutorials and examples. Hopefully we have wetted your appetite for SuperCollider this small Tutorial is just the start for further information it is suggested you visit the following site SuperCollider Help Files To obtain a list of UGens type this reserve word "UGens" (Without the quotes) into your editor highlight and press Control + "U".

Back << SC01 Basics == SC03 Commands Help >> Forward