This example is discussed below in the following sections. Remember, when running
SuperCollider code in
GEdit, you can stop the sound by pressing
Esc
{ SinOsc.ar( 440, 0, 0.2 ); }.play;
"UGen" stands for "unit generator." UGens are special Objects that generate either an audio or a control signal.
The UGen that will be used for most of the experimentation in this Guide, and which was primarily used to generate the "Method One" program that goes with this Guide, is called SinOsc
, which generates a sine wave. The class' name, SinOsc
means "sine oscillator."
The example at the beginning of this chapter, SinOsc.ar( 440, 0, 0.2 );
produces an "instance" of the SinOsc
class, which continuously outputs a signal, based on the parameters given in parentheses. This instance produces an "audio rate" signal, which means that it is of sufficient quality to eventually become sound.
A slightly modified version of that code will give us a "control rate" signal: SinOsc.kr( 440, 0, 0.2 );
There is only one small difference between the two examples - for us - but for SuperCollider, the difference is huge. A control rate signal will not be of sufficient quality to become sound; it is used to control other UGens that do become sound.
Unlike other Classes, UGen Classes should not be instantiated with the new
message. They should always be instantiated as either audio-rate (by passing the ar
message), or control-rate (by passing the kr
message). Control-rate signals are calculated much less often than audio-rate signals, which allows the SuperCollider interpreter and server to save processing power where it wouldn't be noticed.