{
   "labels" : [
      "rain",
      "thunder",
      "wind"
   ],
   "code" : "(\r\n//Global sinusoidal envelope simulates passing of the storm\r\nSynthDef (\\global, {\r\n\targ uitbus, duur;\r\n\tOut.kr(uitbus, EnvGen.kr(Env.sine(duur, 1), doneAction: 2))\r\n}).send(s);\r\n)\r\n\r\n//Rain\r\n// metal sound\r\n(\r\nSynthDef (\\regen, {\r\n\targ inbus;\r\n\tvar trig;\r\n\ttrig=Dust.kr(0.3*In.kr(inbus, 1)); //not to frequent, controlled by global envelope\t \r\nOut.ar(\t\t\t\t\t\t\t\t\t\r\n\t \t0, \r\n\t \tPan2.ar(\t\t\t\t// in, pos, level\r\n\t \t\tSinOsc.ar(\r\n\t \t\t\tTRand.kr(1000, 2000, trig), //every drop has its own frequency\r\n\t \t\t\t0, \t\t\t\t\t//fase\r\n\t \t\t\t0.7 + (0.5* SinOsc.kr(\t//amplitude-modulation\r\n\t \t\t\t\t\t\tTRand.kr(1000, 2000, trig),\r\n\t \t\t\t\t\t\t1.5*pi,\t\t\t//fase\r\n\t \t\t\t\t\t\tTRand.kr(0.0, 1.0, trig)//varying modulation\r\n\t \t\t\t\t\t))\t\t\t\t\t\t//end of modulator\r\n\t \t\t),\t\t\t\t\t\t\t\t//end of SinOsc\r\n\t \t\t\tTRand.kr(-1.0, 1.0, trig),//each drop has its own position in panorama\r\n\t \t\t\t0.1\t\t\t\t\t\t\t\t//low level, to make room for thunder\r\n\t \t)\t\t\t\t\t\t\t\t\t//end of Pan2\r\n\t\t*EnvGen.kr(\r\n\t\t\tEnv.perc(\r\n\t\t\t\t0.01, \t\t\t\t\t\t//short attack\r\n\t\t\t\tTRand.kr(0.1, 1.0, trig), //each drop has its own eigen decay-time\r\n\t\t\t\t1, \t\t\t\t\t\t\t//normal level\r\n\t\t\t\t-8\t\t\t\t\t\t\t//good curve\r\n\t\t\t), \t\t\t\t\t\t\t\t//end of Env\r\n\t\t\ttrig\t\t\t\t\t\t\t//start raindrop\r\n\t\t)\t\t\t\t\t\t\t\t\t//end of EnvGen\r\n\t)\t\t\t\t\t\t\t\t\t\t//end of Out\r\n}).send(s);\r\n)\r\n//Rain with white noise\r\n(\r\nSynthDef (\\regen2, { \r\n\targ inbus;\r\n\tvar trig;\r\n\ttrig=Dust.kr(20*In.kr(inbus, 1)); //many drops, controlled by global envelope\r\n\tOut.ar(\r\n\t\t0, \r\n\t\tPan2.ar(\r\n\t\t\tLPF.ar(\r\n\t\t\t\tWhiteNoise.ar(0.1), \t\t//white noise with low level\r\n\t\t\t\tLFNoise1.kr(0.5, 200, 2000),//slightly varying sound\r\n\t\t\t\t1 \t\t\t\t\t\t\t\t//normal level\r\n\t\t\t)*\t\t\t\t\t\t\t\t\t//end of LPF\r\n\t\t\tEnvGen.kr(\r\n\t\t\t\tEnv.perc(0.005, 0.005, 1, -8), //short attack and decay\r\n\t\t\t\ttrig\r\n\t\t\t),\t\t\t\t\t\t\t\t\t//end of EnvGen\r\n\t\t\tTRand.kr(-1.0, 1.0, trig),\t//each drop has its own position in panorama\r\n\t\t\t1\t\t\t\t\t\t\t\t\t//normal level\r\n\t\t) \t\t\t\t\t\t\t\t\t\t//end of Pan2\r\n\t);\t\t\t\t\t\t\t\t\t\t\t//end of Out\r\n}).send(s);\r\n)\r\n//wind\r\n(\r\nSynthDef(\\wind, {\r\n\targ inbus;\r\n\tvar w1, w2;\t\t\t\t\t\t\t\t//two identical functions, one left, one right\r\n\tw1=RLPF.ar(\r\n\t\tWhiteNoise.ar(1), \t\t\t\t\t//normal level, out level comes later\r\n\t\tLFNoise1.kr(0.5, 1000, 1100)*In.kr(inbus, 1) + 20,//filter controlled by global envelope. \r\n\t\t\t\t\t\t\t\t\t\t\t\t//Beware of low cutoff when using RLPF \r\n\t\tLFNoise1.kr(0.4, 0.45, 0.55),  // 0.55 to 1 varying reciprocal Q\r\n\t\t0.1*In.kr(inbus, 1)\t\t\t//low level, controlled by global envelope\t\r\n\t);\r\n\tw2=RLPF.ar(\r\n\t\tWhiteNoise.ar(1), \r\n\t\tLFNoise1.kr(0.5, 1000, 1100)*In.kr(inbus, 1) + 20,\r\n\t\tLFNoise1.kr(0.4, 0.45, 0.55), \r\n\t\t0.1*In.kr(inbus, 1)\r\n\t);\r\n\tOut.ar(0,[w1, w2] )\r\n}).send(s);\r\n)\r\n\r\n//Thunder. Obviously filtered noise with two triggers: 1 for rumbling en 1 to start a thunderclap\r\n(\r\nSynthDef (\\donder, {\r\n\targ inbus;\r\n\tvar trig1, trig2;\r\n\ttrig1=Dust.kr(0.05\t* In.kr(inbus, 1));//slow trigger for each thunder, controlled by global envelope\t\r\ntrig2=Dust.kr(15);\t\t\t\t\t\t//fast trigger for rumbling\r\n\tOut.ar(0,\r\n\t\tFreeVerb.ar( \r\n\t\t\tPan2.ar(\r\n\t\t\t\tRLPF.ar(\t\t\t\t\t\t//filter, in, freq, rq, mul, add\r\n\t\t\t\t\tWhiteNoise.ar(1),\t\t//white noise is the basis\r\n\t\t\t\t\t1500 *\t\t\t\t\t\t//maximum frequency\r\n\t\t\t\t\tEnvGen.kr(\t\t\t\t//how one thunder goes\r\n\t\t\t\t\t\tEnv.perc(\t0.05, 16, 1, -1),//attack, release, peak, curve\r\n\t\t\t\t\t\ttrig1\t\t\t\t\t//slow trigger\r\n\t\t\t\t\t)\t\t\t\t\t\t\t//end of EnvGen for frequency\r\n\t\t\t\t\t* In.kr(inbus, 1) + 20,// bad things happen when frequency = 0\r\n\t\t\t\t\t0.55,\t\t\t\t\t\t// reciprocal Q\r\n\t\t\t\t\tEnvGen.kr(\t\t\t\t//rumbling, controls amplitude\r\n\t\t\t\t\t\tEnv.perc(0.01, 0.5, 2, -1),\r\n\t\t\t\t\t\ttrig2\t\t\t\t\t//fast trigger\r\n\t\t\t\t\t)\t\t\t\t\t\t\t// end of for amplitude\r\n\t\t\t\t),\t\t\t\t\t\t\t\t//end of LPF\r\n\t\t\t\tLFNoise1.kr(0.1)\t\t\t//freq\r\n\t\t\t),\t\t\t\t\t\t\t\t\t//end of Pan2\r\n\t\t\t0.5,\t\t\t\t\t\t\t\t//mix\r\n\t\t\t0.75,\t\t\t\t\t\t\t\t//room\r\n\t\t\t0.5\t\t\t\t\t\t\t\t\t//damp\r\n\t\t)\t\t\t\t\t\t\t\t\t\t//einde FreeVerb\r\n\t)\r\n}).send(s)\r\n)\r\n\r\n//Global controlbus\r\nb=Bus.control(s, 1);\r\ng=Synth(\\global, [\\uitbus, b, \\duur: 300]); //300 is number of seconds. Change this if you like\r\n//Here comes the rain\r\nr=Synth.after(g, \\regen, [\\inbus, b]);\r\nq=Synth.after(g, \\regen2, [\\inbus, b]);\r\n//here comes the wind\r\nw=Synth.after(g, \\wind, [\\inbus, b]);\r\n//thunder\r\nd=Synth.after(g, \\donder, [\\inbus, b]);\r\n\r\nd.free;\r\nr.free;\r\nq.free;",
   "id" : "1-29o",
   "is_private" : null,
   "name" : "Thunderstorm",
   "author" : "Henk Lasschuit",
   "description" : "A thunderstorm, made with SuperCollider. There are three layers of sounds: rain, wind and thunder. \r\nThere is a global envelope controlling the density of the raindrops and the thunder as well as the frequency of the wind. For the rain there are ticks of noise, but also a few drops falling on metal objects. I like that sound. \r\nFor the wind there are two identical functions, one plays in the left channel and one plays right. Thunder is the most complicated of them all. It is filtered noise with a slow trigger for making a thunderclap and a fast trigger for the rumbling within a thunder. I added some FreeVerb to make it more spatial.",
   "ancestor_list" : []
}
