// Sound sketch for rain, multichannel ideas...

p = ProxySpace.push;

ProxySynthDef.sampleAccurate_(true);

~drop = { |freq=500, rise=1.4, sus=0.1, amp=0.1, pan=0.0, att=0.1|
	Pan2.ar(
		SinOsc.ar(XLine.kr(freq, freq * rise, 0.1), att * 0.5pi)
		* (XLine.kr(amp, amp * 0.01, sus, doneAction: 2)
			* AmpComp.ir(freq)),
		pan
	);
};

~drop.play;

~drop.spawn([\freq, 600]);

~drop.spawn([\freq, 800, \sus, 0.05]);

~drop.spawn([\freq, 800, \sus, 0.01]);

(			// 16-20% in proxyspace
Tdef(\rain, { 
	loop { 	
		~drop.spawn([
			\out, rrand(0, 24),
			\freq, rrand(300, 1000), 
			\sus, exprand(0.02, 0.03),
			\amp, exprand(0.001, 0.03),
			\pan, 1.0.rand2,
			\att, 0.0.rand
		]);
		(exprand(0.0001, 0.01) * 0.25).wait;
	}
}).play;
)

mm / day -> probability for rain there. 
fall fuer den Himmel im CUBE! 

6 * 13 = 78, 
8 * 13 = 104 ... 

difference: 
	swing backs between here and there? 
	sonst wie? 

CUBEScope.new

// same in with SynthDef, ready for multichannel...
(
SynthDef(\drop, { |out = 0, freq=500, rise=1.4, sus=0.1, amp=0.1, pan=0.0, att=0.1|
	var sound = Pan2.ar(
		SinOsc.ar(XLine.kr(freq, freq * rise, 0.1), att * 0.5pi)
		* (XLine.kr(amp, amp * 0.01, sus, doneAction: 2)
			* AmpComp.ir(freq)),
		pan
	);
	OffsetOut.ar(out, sound);
}, \ir ! 10).store;
)

(			// 16-20% in proxyspace
Tdef(\rain, { 
	loop { 	
		s.sendBundle(0.2, [ "s_new", \drop, -1,0,0,
			\out, rrand(0, 6),
			\outI, rrand(0, 3),
			\outJ, rrand(0, 5),
			\freq, rrand(300, 1000), 
			\sus, exprand(0.02, 0.03),
			\amp, exprand(0.001, 0.03),
			\pan, 1.0.rand2,
			\att, 0.0.rand
		]);
		(exprand(0.001, 0.01) * 0.2).wait;
	}
}).play;
)

		// teuer!!!
(
SynthDef(\drop, { |out = 0, freq=500, rise=1.4, sus=0.1, amp=0.1, pan=0.0, att=0.1|
	var sound = PanAz.ar(12,
		SinOsc.ar(XLine.kr(freq, freq * rise, 0.1), att * 0.5pi)
		* (XLine.kr(amp, amp * 0.01, sus, doneAction: 2)
			* AmpComp.ir(freq)),
		pan
	);
	OffsetOut.ar(out, sound);
}, \ir ! 10).store;
)
	// fuer quadrat-gitter:
(
SynthDef(\drop, { |outI = 0, outJ =0, panI = 0, panJ=0, 
	freq=500, rise=1.4, sus=0.1, amp=0.1, att=0.1|
	var jsize = 5; 
	var outJ1 = outJ * jsize; 
	var outJ2 = outJ + 1 * jsize; 
	var outI2 = outI + 1; 
	
	var sound = SinOsc.ar(XLine.kr(freq, freq * rise, 0.1), att * 0.5pi)
		* (XLine.kr(amp, amp * 0.01, sus, doneAction: 2)
			* AmpComp.ir(freq));
	sound = Pan4.ar(sound, panI, panJ);
	
	OffsetOut.ar(outJ1 + outI, sound[0]);
	OffsetOut.ar(outJ1 + outI2, sound[1]);
	OffsetOut.ar(outJ2 + outI, sound[2]);
	OffsetOut.ar(outJ2 + outI2, sound[3]);
}, \ir ! 10).store;
)

(
SynthDef(\drop, { |out = 0, freq=500, rise=1.4, sus=0.1, amp=0.1, pan=0.0, att=0.1|
	var sound = TorusPanAz.ar([12,8,4], 
		SinOsc.ar(XLine.kr(freq, freq * rise, 0.1), att * 0.5pi)
		* (XLine.kr(amp, amp * 0.01, sus, doneAction: 2)
			* AmpComp.ir(freq)),
		pan, 
		pan
	);
	OffsetOut.ar(out, sound);
}, \ir ! 10).store;
)