Designing Sound in SuperCollider/Rain

From Wikibooks, open books for an open world
Jump to: navigation, search

Fig 38.1: Fluid sphere impact[edit]

The waveform produced by impact of fluid sphere on hard surface - we'll create it as a Function here so we can reuse it:

~dropletonhard = {|dur=0.0005| Env.perc(dur/2, dur/2, 1, [-4, 4])};

Fig 38.3: obtaining a Gaussian noise distribution.[edit]

The Central Limit Theorem tells us that adding together independent noise sources will eventually give us gaussian noise. Twelve is certainly enough for auditory purposes.

x = { {}.dup(12).mean.dup * 0.5}.play;;

In the book, Andy says that it is more efficient to use two white noise sources and to create a gaussian shape using the Box-Muller transform. However, this involves some relatively heavy mathematical operations (log, cos, sqrt) so it's not actually obvious which approach is more efficient on a given system. Compare the CPU usage (and the audio result) of the above, with the following:

x = {
	var,1); // move mouse left/right to change amount
	var n1 = * amount + (1-amount);
	var n2 =;
	var gaussian = sqrt(-2 * log(n1)) * cos(n2);
	gaussian.dup * 0.5

Fig 38.4: raindrop pressure on solid ground[edit]

x = {
	var gaus, osc;
	gaus = {}.dup(12).sum;
	gaus =, 50, 1/0.4), 500);
	osc =, 1, 40, 80)) * gaus.squared * 10;
	osc = (osc - 0.35).max(0);{
		osc =, 500);