SC04 Basics More Commands

SuperCollider - Tutorial 04 (More Commands)

Authored by Derek Shaw

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

Blip = Band limited impulse oscillator
XLine = Exponential line generator
Line = Line generator
DynKlang = Sine oscillator bank
loop = loop
Rand = Random Number generator
Pan2 = two channel equal power pan
EnvGen = Evelope generator
wait = Self explanatory
fork = Undocumented (No help file)
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
XLine.ar(start, end, dur, mul, add, doneAction)
XLine.kr(start, end, dur, mul, add, doneAction)
Line.ar(start, end, dur, mul, add, doneAction)
Line.ak(start, end, dur, mul, add, doneAction)

This Tutorial

Basic's 04 looks at some more common Commands used in SuperCollider and certainly not all of them, in this tutorial we focus on how to retrieve the help information for a given command set and practice with the examples given from the help file. You might like to know how we obtained this information, well we typed the word "UGens" into the editor highlighted the word as we did to obtain help for the command words used previously we then selected Oscillators. You can also provided you have installed supercollider-docs jump directly to the file using this link Copy here link location Paste into browser URL and press return.

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

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


// Press ESC Key to stop Audio Signal to Server
)

The commands and examples we intended to look at in this tutorial include the following Blip, XLine, Line and DynKlang again we will use the code blocks within the help files to demonstrate the principles of the code.

Blip has two example code blocks so lets run them and see what they do:-)

( // Move edit cursor and press CTRL+E here to run
// modulate frequency
{ Blip.ar(XLine.kr(20000,200,6),100,0.2) }.play;
// Press ESC Key to stop Audio Signal to Server
)

It is a lot easier to play the code and listen to what it does than to describe it, but if could it would sound like a high frequency tone ramping down fairly rapidly to a sustained low frequency hum.

( // Move edit cursor and press CTRL+E here to run
// modulate harmonics
{ Blip.ar(200,Line.kr(1,100,20),0.2) }.play;
// Press ESC Key to stop Audio Signal to Server
)

On the other hand the example above exhibits a very different behaviour that appears to my ears have an underlying low frequency tone sitting on top of a stepped progression from low to high frequency ramp, this is not quite the inverse of the code block above for a start the code used is different.

There are many ways you could combine these code blocks together the easiest way is to run the second code block on top of the first, by that I mean we could run each code blocks on separate entries but simultaneously. I thought I would tackle this myself with a slightly different approach you might like to have a go yourself, if you do please post you solutions as a comment, or register with us and develop these tutorials yourself.

My code block

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

// modulated frequency and harmonics
{ [(Blip.ar(XLine.kr(20000,200,6),100,0.2)),(Blip.ar(200,Line.kr(1,100,20),0.2))] }.play;
// Press ESC Key to stop Audio Signal to Server
)

Well I am not a programmer but my aim was to use both of the previous code blocks and if possible both channels. That is not to say that my approach is the correct one in fact I probably broke some rules to achieve it, but work it does so definitely a plus as far as I am concerned at that is really the point of the exercise and that of this tutorial.

We are going now to look at a new command we have not used before called DynKlang if we access the help file for this command it is described as a Sine oscillator bank what ever that is we have two example programs we can try.

( // Move edit cursor and press CTRL+E here to run
// frequency modulation play {
DynKlang.ar(`[
[800, 1000, 1200] + SinOsc.kr([2, 3, 4.2], 0, [13, 24, 12]),
[0.3, 0.3, 0.3],
[pi,pi,pi]
]
) * 0.1
};
// Press ESC Key to stop Audio Signal to Server
)

I can't tell what it does or really how it does it so my suggestion for what it is worth is to dabble at modifying the existing values or perhaps make some additions of your own that don't break the workings of the original code.

( // Move edit cursor and press CTRL+E here to run
// building new synths every 2 seconds
{
loop({
play({
var mod = SinOsc.kr(Rand(0.1, 0.9), 0, Rand(5, 20));
Pan2.ar(DynKlang.ar(`[ Array.rand(12, 200.0, 2000.0), 1, mod ]), 1.0.rand)
* EnvGen.kr(Env.sine(4), 1, 0.02, doneAction: 2);
});
2.wait;
})
}.fork;
// Press ESC Key to stop Audio Signal to Server
)

True, we are not using anything more than the examples that are already there in the help file documentation but these tutorials are aimed at the novice not a hardened SuperCollider programmer, programmers do not grow on trees they like the rest of us need to learn from basic principles and structure. Previous tutorials concentrated more on the structure element than the code itself, in order to encourage new SuperCollider users and ease that of the novice to obtain audio from any code sample given. There are very few comprehensive tutorials for the novice user, in fact if I could direct you to a suitable sight I would. So if you know of any post a comment at the bottom and help others learn from your knowledge.

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 << SC03 Help