(
SynthDef(\add_do, {
	arg freq = 440, amp = 0.5, out = 0;
	var sig = 0, freqs = Array.series(15, 1, 2);
	freqs.do({ |f, i|
		var pulse;
		pulse = Pulse.ar(
			freq * f * ExpRand(0.91, 0.90),
			mul: i.linexp(0, freqs.size - 1, 1, 0.0001)
		);
		pulse = Pan2.ar(pulse, Rand(-0.9, 0.9));
		sig = sig + pulse;
	});
	sig = sig * Env([0, 1, 0], [5, 5], [1, -2]).kr(2);
	sig = sig.blend(GVerb.ar(sig.sum, 100, 4), 0.15);
	sig = LPF.ar(sig, (freq.midicps * XLine.kr(2, 10, 16)).clip(20, 20000));
	sig = Splay.ar(sig.scramble, 0.5);
	sig = sig * 0.1 * amp;
	Out.ar(out, sig);
}).add;
)

// We can use iteration to create multiple Synths. Because of the randomness (ExpRand) applied to the frequencies of the sine waves, we'll hear beating patterns.

23.do({ Synth(\add_do, [freq: 40.midicps]) });



(
[38, 50, 57, 59, 66].do({ |note, index|
	3.do({
		Synth(
			\add_do, [
				freq: note.midicps,
				amp: index.linexp(0, 4, 0.6, 0.2),
			]
		)
	});
});
)



(
SynthDef(\add_do, {
	arg freq = 440, amp = 0.1, out = 0;
	var sig = 0, freqs = Array.series(15, 1, 2);
	freqs.do({ |f, i|
		var osc;
		osc = PulseDPW.ar(
			freq * f * ExpRand(0.99, 1.01),
			mul: i.linexp(0, freqs.size - 1, 1, 0.0001)
		);
		osc = Pan2.ar(osc, Rand(-0.9, 0.9));
		sig = sig + osc;
	});
	sig = sig * Env([0, 1, 0], [5, 5], [1, -2]).kr(2);
	sig = sig * amp;
	Out.ar(out, sig);
}).play;
)


(
SynthDef(\add_do, {
	arg freq = 440, amp = 0.1, out = 0;
	var sig = 0, freqs = Array.series(15, 1, 2);

	sig = Pulse.ar(freq)!2;


	sig = sig * amp;
	Out.ar(out,sig);
}).play;
)

3.do({ Synth(\add_do, [freq: 64.midicps]) });
