Deterministic Soundscape

I was recently working with a student on a composition that involved subtle, controllable sample playback.  We were doing this in Supercollider because it is free and coming up with ways of randomly triggering city sounds throughout the composition is easy to program and a great learning opportunity.  The little bit of code below is easy and fun way to randomly trigger sounds.

 

b = SoundFile.collectIntoBuffers(“path/*”,s) // path/* will load a folder with all the sound int he folder.  The * is kind of like a place holder for all the file names in the folder

SynthDef(“playback”, {arg bufnum, rep = 0, speed = 1;

var play;
play = PlayBuf.ar(1, bufnum, rate: speed, loop: rep, doneAction:2);

Out.ar(0, play);

}).send(s)

b = Synth(“playback”, [\bufnum, rrand(0,5)] )

c = Synth(“playback”, [\bufnum, rrand(0,5)] )

etc…..

 

What made this a good little lesson for class was the use of rrand vs. Rand, NRand, TRand, etc.

We could use Rand or some variation but if we want to change a range of numbers halfway through the piece we are unable to because Rand() is a Ugen that can’t be used in a control (Synth.new).  rrand(), however, can be used in a control and allows the user to set a range.  This is particularly use when trigger back different samples from a range of samples or different frequencies from a range.

With any random function in supercollider it is a range of values from either 0 – inf or x, y, but we can select from a particular set of values by using an array and .choose.

[1, 5, 4, 8, 6, 9, 7].choose // this makes every number have equal probability of occurring.

We can use wchoose([]) to have weights. wchoose has to have weightd that add up to 1

[4, 7, 1, 3, 456, 8, 9].wchoose([0.7, 0.1, 0.05, 0.04, 0.01, 0.05, 0.05])

Finally in the above code we use doneAction 2 in the SynthDef so when the sample is done playing it frees from the node.  This allows us to layer many samples and not use to much processing power.

 

As with my other posts.  If you enjoy them, find anything useful or have used my software please consider donating to my hurdy gurdy fund on my home page.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s