SC-03 Basics Commnd Set

SuperCollider - Tutorial 03 (Basics Command set)

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

SinOsc = Sine Oscillator
LFNoise0 = 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
Out = write a signal to a bus
XLine.ar(start, end, dur, mul, add, doneAction)
XLine.kr(start, end, dur, mul, add, doneAction)

This Tutorial

Basic's 03 looks at some of the most common of Command set 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.

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
)

Most of the code examples below you have already seen so from that perspective we are repeating ourselves. Provided you have installed supercollider-docs along with the application you will be able to access the same information in the same way as us.

( // Move edit cursor and press CTRL+E here to run
// Double click on SinOsc to highlight this word then press Ctrl + "U"
{SinOsc.ar}.play;
)

In order to access help on any given command you need to select the appropriate command with your mouse or by using the shift and cursor keys, all of the command needs to be selected including any specified value immediately after the command but before any control codes such as ".ar or .ak" if applicable. If we take the above command as an example SinOsc is the command we are looking at if this is selected by a double click over the command with the mouse the simplest method, or we can alternatively use the cursor keys to be positioned before the capital "S" then using both Shift key and right cursor key highlight the command word "SinOsc ". Once selected you can use Control key plus "U" the Internet browser should then be launched with the help file appropriate for the command selected.

===========================================

This is the help file displayed for the above command when selected:

SinOsc interpolating sine wavetable oscillator

SinOsc.ar(freq, phase, mul, add)

Sinusoidal oscillator; a sine tone.

Note: This is the same as Osc except that the table has already been fixed as a sine table of 8192 entries.

freq - frequency in Hertz

phase - phase offset or modulator in radians

{ SinOsc.ar(200, 0, 0.5) }.play;


// modulate freq

{ SinOsc.ar(XLine.kr(2000, 200), 0, 0.5) }.play;


// modulate freq

{ SinOsc.ar(SinOsc.ar(XLine.kr(1, 1000, 9), 0, 200, 800), 0, 0.25) }.play; 



// modulate phase

{ SinOsc.ar(800, SinOsc.ar(XLine.kr(1, 1000, 9), 0, 2pi), 0.25) }.play;

Here the first of the example codes supplied is pasted into our template more for convenience than anything else:

( // Move edit cursor and press CTRL+E here to run
//phase - phase offset or modulator in radians
{ SinOsc.ar(200, 0, 0.5) }.play;
// Press ESC Key to stop Audio Signal to Server
) This bracket must be on a line on its own

Now the help file conveniently printed above shows us some alterations we can make to the SinOsc command changes that allow us to alter the performance of the command itself, such alterations are known as modifiers and in this particular case we can adjust the output for frequency, multiplier and addition.

The above modifiers have been set as follows:

freq=200
mul=0
add=0.5

Each of these modifiers above does something, what we encourage you to do is to change the values and monitor the audio output see what effect modifying these values has. There is nothing value wise you can change that will harm your computer so make some mistakes and have some fun.

( // Move edit cursor and press CTRL+E here to run
// Example
// modulate freq
{ SinOsc.ar(XLine.ak(2000, 200), 0, 0.5) }.play;
// Press ESC to end
)

Here we have pasted the second of the example codes available and in doing so been introduced to a new command that of "XLine". This is the true nature of accessing help files this way as it can be an invaluable source for new material and code structure definitions with examples of codes structures that as far as we know for the most part work. In this example XLine and its parameters are being used to adjust the frequency of SinOsc before mul and add are defined with fixed values. The ".kr" definition adjusts the control rate.

( // Move edit cursor and press CTRL+E here to run
//Modulate freq
{ SinOsc.ar(SinOsc.ar(XLine.kr(1, 1000, 9), 0, 200, 800), 0, 0.25) }.play;
// Press ESC Key to stop Audio Signal to Server
)

The last two code blocks where examples of Modulated frequency however there is another type frequency variation for sound it is known as Phase modulation. Below is an example of code that varies the phase of the sound output.

( // Move edit cursor and press CTRL+E here to run
// modulate phase
{ SinOsc.ar(800, SinOsc.ar(XLine.kr(1, 1000, 9), 0, 2pi), 0.25) }.play;
// Press ESC Key to stop Audio Signal to Server
)

It is difficult to define quite what is going on here at first glance it looks like a way to produce stereo output however this is not the case.

Please Note the following

The code structure below shows a command we again have come across before that of "LFNoise0" if you try to double click this to highlight the word only LFNoise gets highlighted, try to obtain help on this command and it won't find it. This is due to the fact that the command selected is incomplete, by that we mean that you have only partially selected the command to obtain help on, to rectify this oversight you need in this instance to select the "0" component in addition to that of the command:-

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

===========================================

XLine exponential line generator

XLine.ar(start, end, dur, mul, add, doneAction)

XLine.kr(start, end, dur, mul, add, doneAction)

Generates an exponential curve from the start value to the end value. Both the start and end values must be non-zero and have the same sign.

start - starting value

end - ending value

dur - duration in seconds

doneAction - a doneAction to be evaluated when the Line is completed. See UGen-doneActions for more detail.

play({ SinOsc.ar(XLine.kr(200,17000,10),0,0.1) });

As you can see the help file suggest some new was in which you can code with it, the purpose here is to enhance your knowledge and broaden the scope of commands you could use. Again as with all the codes we have published so far, you are encouraged to try out the examples given.

( // Move edit cursor and press CTRL+E here to run
play({ SinOsc.ar(XLine.kr(200,17000,10),0,0.1) });
// 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 << SC02 Basics || SC04 More Commands >> Forward