Difference between revisions of "SuperCollider Cookbook"

From CCRMA Wiki
Jump to: navigation, search
Line 22: Line 22:
 
==Looping==
 
==Looping==
  
 +
'''While'''
 +
 +
<pre>(
 +
i = 0;
 +
while ( { i < 5 }, { i = i + 1; "boing".postln });
 +
)</pre>
 +
 +
'''For'''
 +
 +
<pre>for (3, 7, { arg i; i.postln }); // prints values 3 through 7</pre>
 +
 +
'''ForBy'''
 +
 +
<pre>forBy (0, 8, 2, { arg i; i.postln }); // prints values 0 through 8 by 2's</pre>
 +
 +
'''Do'''
 +
 +
<pre>[ "first", "second", "third", 444) ].do({ arg item, i; [i, item].postln; });
 +
 +
5.do({ arg item; item.postln }); // iterates from zero to four
 +
 +
"you".do({ arg item; item.postln }); // a String is a collection of characters
 +
 +
'they'.do({ arg item; item.postln }); // a Symbol is a singular item
 +
 +
(8..20).do({ arg item; item.postln }); // iterates from eight to twenty 
 +
 +
(8,10..20).do({ arg item; item.postln }); // iterates from eight to twenty, with stepsize two
 +
</pre>
  
 
==Amplitude Modulation==
 
==Amplitude Modulation==

Revision as of 17:53, 8 June 2011

SuperCollider Cookbook by Bruno

Play a sound file

simple play

Do this.

varying speed

Do that.

changing direction

Do this and that.

Play a MIDI file

Do this and that.

List Operations

scramble

reverse

find nth

Looping

While

(
i = 0;
while ( { i < 5 }, { i = i + 1; "boing".postln });
)

For

for (3, 7, { arg i; i.postln }); // prints values 3 through 7

ForBy

forBy (0, 8, 2, { arg i; i.postln }); // prints values 0 through 8 by 2's

Do

[ "first", "second", "third", 444) ].do({ arg item, i; [i, item].postln; });

5.do({ arg item; item.postln }); // iterates from zero to four

"you".do({ arg item; item.postln }); // a String is a collection of characters

'they'.do({ arg item; item.postln }); // a Symbol is a singular item

(8..20).do({ arg item; item.postln }); // iterates from eight to twenty 

(8,10..20).do({ arg item; item.postln }); // iterates from eight to twenty, with stepsize two

Amplitude Modulation

Frequency Modulation

Additive Synthesis

Subtractive Synthesis