
( // latoocarfian trig and 2DC ...
SynthDef(\latooTriggers, { |out, trigA=1.1|
	var trig, sig;
	
	trig = LatoocarfianTrig.kr(
		minfreq: 4,
		maxfreq: 12,
		//a: [1.1,1.9] // or 1.9?
		a: trigA
	); 
	
	sig = Latoocarfian2DC.ar(
		minfreq: 420,
		maxfreq: 8200,
		a: Lag.kr(TRand.kr(0.4, 0.8, trig), 0.1),
		b: Lag.kr(TRand.kr(2.0, 3.0, trig), 0.1),
		//d:[1.0, 1.1]
		d:1.1
	);

	sig = (sig.cubed * 2).tanh;

	sig = sig + (BrownNoise.ar() * 0.1);

	sig = Ringz.ar(in:sig, freq: LFNoise2.kr(2).exprange(50,15000), decaytime: 0.02)*0.1;

	sig = (sig*0.4).fold2(0.9) + sig.excess(0.5).clip2(0.9); //!!

	sig = sig * Latch.kr(trig, trig);

	/*	sig = sig + JPverb.ar(
		in: sig * 0.2,
		t60: LFNoise2.ar(0.4).range(0.2,3),
		damp:0.8,
		modDepth:0.3,
		modFreq:10); */
	
	sig = LeakDC.ar(sig * 0.6);

	Out.ar(out,sig);
	
}).add;
);




( // LatoocarfianC being thrown around
SynthDef(\latooThroBass, {

	arg out, amp=0.5;

	// wandering latoocarfian into variable 'freq':
	var freq = LatoocarfianC.ar(
		30,
		// randomize parameters:
		LFNoise2.kr(0.1,1.5,1.5),
		LFNoise2.kr(0.4,1.5,1.5),
		LFNoise2.kr(0.3,0.5,1.5),
		LFNoise2.kr(0.2,0.5,1.5)
	).range(40,130);

	// wandering latoocarfian applied as frequency to squarewave:
	var sig = Mix(Pulse.ar([freq,freq*0.99]));

	// adding sinwave for more clean deep sound
	sig = sig + Mix(SinOsc.ar([freq*0.998,freq*0.995]));

	
	// pinch of simple fold distortion
	sig = sig.fold(-1,1);

	// low pass filter to give sense of closing and opening
	sig = LPF.ar(sig, LFNoise2.kr(1).exprange(50,15000));

	// add space. lots of space
	//sig = sig * 0.4 + Greyhole.ar(sig * 0.4, delayTime:0.4, damp: 0.3, diff: 0.6, feedback:0.5,);

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



( // LatoocarfianC being thrown around
SynthDef(\latooWanderings, {
	arg out = 0, gate = 1, fadeTime = 1, amp = 0.9;

	// a fade-in/out envelope
	var env = EnvGen.kr( Env([0, 1, 0], [fadeTime, fadeTime], \sin, 1),
        				 gate, levelScale: amp, doneAction: Done.freeSelf );
	
	// wandering latoocarfian into variable 'freq':
	var freq = LatoocarfianC.ar(
		freq: 30,
		// randomize parameters:
		a: LFNoise2.kr(0.1,1.5,1.5),
		b: LFNoise2.kr(0.4,1.5,1.5),
		c: LFNoise2.kr(0.3,0.5,1.5),
		d: LFNoise2.kr(0.2,0.5,1.5)
	).range(40,130);

	// wandering latoocarfian applied as frequency to squarewave:
	var sig = Pulse.ar(freq * LFNoise2.kr(0.1).range(0.99,1.01));

	// adding sinwave for more clean deep sound
	//sig = sig + SinOsc.ar([freq*0.998,freq*0.995]);
	sig = sig + SinOsc.ar(freq * LFNoise2.kr(0.1).range(0.99,1.01));

	
	// pinch of simple fold distortion
	sig = sig.fold2(0.9);

	// low pass filter to give sense of closing and opening
	sig = LPF.ar(sig, LFNoise2.kr(1).exprange(50,15000));

	// add space. lots of space
	// sig = sig * 0.4 + Greyhole.ar(sig * 0.4, delayTime:0.4, damp: 0.3, diff: 0.6, feedback:0.5,);

	sig = sig * env;
	
	Out.ar(out, sig);
}).add;
);






















