# Designing Sound in SuperCollider/Rain

## Fig 38.1: Fluid sphere impact

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])};
~dropletonhard.value.plot
```

## Fig 38.3: obtaining a Gaussian noise distribution.

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 = { {WhiteNoise.ar}.dup(12).mean.dup * 0.5}.play;
x.free;
```

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 amount=MouseX.kr(0,1); // move mouse left/right to change amount
var n1 = WhiteNoise.ar.abs * amount + (1-amount);
var n2 = WhiteNoise.ar(2pi);
var gaussian = sqrt(-2 * log(n1)) * cos(n2);
gaussian.dup * 0.5
}.play;
)
x.free;
```

## Fig 38.4: raindrop pressure on solid ground

```(
x = {
var gaus, osc;
gaus = {WhiteNoise.ar}.dup(12).sum;
gaus = LPF.ar(BPF.ar(gaus, 50, 1/0.4), 500);

osc = SinOsc.ar(gaus.linlin(-1, 1, 40, 80)) * gaus.squared * 10;
osc = (osc - 0.35).max(0);

2.do {
osc = HPF.ar(osc, 500);
};

osc.dup
}.play
)
```