Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07...

19
Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008

Transcript of Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07...

Page 1: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Computer Programming For Musical Applications II

Tutorial 05

SuperCollider Sound Fundamentals

07 November, 2008

Page 2: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Tutorial Overview

Sonic startupSine Wave Unit GeneratorAudio Rate & Control RateLine & XLine Unit GeneratorsNoiseExercise’s

207 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 3: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Sonic StartupHere is how you can get some basic sound in SuperCollider:

First you need to start up the server, this is automatically assigned to the variable s when SC first loads.You can either boot up the localhost server by using the code:

or by hitting the Boot button on the localhost server GUI paneWhen it boots you should see the Boot button change to Quit and turn green

s.boot;

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 4: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Sonic Startup

Now your ready to play some sound:

One of the most basic ways of getting sound is to play a sine wave using the SinOsc Unit Generator (UGen):

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

UGen Audio rate Frequency (Hz) Phase Amplitude

Press the Enter button to make this play. Use the keys CMD . to make it stop

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 5: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Sonic Startup

Notice the { } brackets around the UGen method call, this is actually placing the UGen call inside a function. Due to the Object Orientated nature of SC (i.e. EVERYTHING in SC is an Object), a function knows how to play itself...hence why we get sound.

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

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

This allows us to place the function inside a variable:

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 6: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Sonic StartupTask 1.1:

Startup SCBoot the serverPlay some sound using the SinOsc Unit Generator

{ SinOsc.ar(freq, phase, amp) }.play;

Task 1.2:

Modify your code so you use three different variables to control the frequency, phase and amplitude parameters of the SinOsc

Use the syntax var myVariable = value; to create a variable

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 7: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Audio Rate & Control RateThere are two different sample rates to use in SC:

AUDIO RATE & CONTROL RATE

Unit Generators to which an ar message is sent will run at audio rate, this is 44,100 samples per second by default.

Unit Generators to which a kr message is sent will run at control rate, by default control rate ugens will generate one sample for every 64 samples made by an audio rate ugen. They therefore run at 689 samples per second.

Control rate ugens are useful for controlling the parameters of audio rate ugens, such as frequency or amplitude

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 8: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Audio Rate & Control Rate

(a = { SinOsc.kr(5,0,10) };b = { SinOsc.ar(200+a, 0, 0.5) };b.play;)

Here a SinOsc UGen at control rate is used to control the frequency of another SinOsc UGen that is at audio rate

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 9: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Audio Rate & Control RateTask 2.1:

Use one SinOsc at control rate to control the frequency of another SinOsc at audio rate. Place each UGen in a separate function to make things easier

Task 2.2

Create another SinOsc at control rate to control the amplitude of the SinOsc that is running at audio rate

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 10: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

We can also use other UGens to control the parameters of our SinOsc. The Line UGen will create a line from a start value to an end value over a specified duration. It can be created using either audio rate or control rate.

(a = { Line.kr(0,500,5) };b = { SinOsc.ar(200+a, 0, 0.5) };b.play;)

Here a Line UGen is created and used to control the frequency of a SinOsc UGen. The line will go from 0 to 500 over 5 seconds

Line Unit Generator

Line’s syntax: Line.kr(start, end, duration);

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 11: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

The XLine UGen will do the same as the Line UGen, with the exception that it will create an exponential curve rather than a straight line.

(a = { XLine.kr(200,12000,10) };b = { SinOsc.ar(a, 0, 0.5) };b.play;)

Here an XLine UGen is created and used to control the frequency of a SinOsc UGen. The curve will go from 200 to 12000 over 10

seconds

XLine Unit Generator

XLine’s syntax: Xline.kr(start, end, duration);

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 12: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Task 3.1:

Use a Line UGen at control rate to control the frequency of another SinOsc at audio rate. Make the frequency of the SinOsc UGen raise from 200Hz to 15000Hz over 10 seconds.

Task 2.2

Use an XLine UGen at control rate to control the frequency of another SinOsc at audio rate. Make the frequency of the SinOsc UGen raise from 200Hz to 15000Hz over 10 seconds.

Play both of these and listen to the difference between them

Line & XLine Unit Generator’s

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 13: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Noise

Noise syntax: NoiseUGen.ar(amplitude);

There are several basic noise UGens, they all use the same santax:

For example:

White Noise syntax: WhiteNoise.ar(0.1);

Pink Noise syntax: PinkNoise.ar(0.1);

Brown Noise syntax: BrownNoise.ar(0.1);

Gray Noise syntax: GrayNoise.ar(0.1);

Clip Noise syntax: ClipNoise.ar(0.1);

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 14: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Noise

More interesting noise UGens: Dust & Dust2

Dust syntax: Dust.ar(density,amplitude);

Dust generates random impulses from 0 to 1, the density argument specifies the number of impulses per second

( a = { XLine.kr(1,200,10) }; b = { Dust.ar(a, 0.5) }; b.play;)

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 15: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

More interesting noise UGens: Crackle

Crackle syntax: Crackle.ar(param,amplitude);

Crackle generates noise based on a chaotic function, the param parameter is the value of the chaotic function with useful values from

just below 1.0 to just above 2.0

( a = { XLine.kr(1.0,2.0,5) }; b = { Crackle.ar(a, 0.5) }; b.play;)

Noise

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 16: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

NoiseTask 4.1

Test each of the Noise UGen’s below independently and compare how they sound:

White Noise

Pink Noise

Brown Noise

Gray Noise

Clip Noise

Noise syntax: NoiseUGen.ar(amplitude);

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 17: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

NoiseTask 4.2

Use the Line UGen to control the density of a Dust UGen

Task 4.3

Use the XLine UGen to control the chaos function of a Crackle UGen

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 18: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.

Look up the SC Help file (press CMD + d to open it)Select the Tour of Unit Generators link in the Tutorials section

Play with the following UGens:

SawLFNoise0

Then use the Low Pass Filter UGen ( LPF ) to filter the Saw UGen.

Tip - If the text in the help file is blue then you can access specific help about that item. Select the text and press CMD + d to bring up the item’s help file.

TASKS

07 November, 2008 MTE2007 Computer Programming For Musical Applications II

Page 19: Computer Programming For Musical Applications II Tutorial 05 SuperCollider Sound Fundamentals 07 November, 2008.