// TODO: add modulation to chain params

// 02

(
SynthDef(\layer0_struct0, {
	arg bufnum, fftSize = 1024, amp = 0.3;

	var in, chain, dry, fx;
	var wipe, trig;
	var sig;

	// Audio input
	in = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum));


	// FFT
	chain = FFT(LocalBuf(fftSize), in);


	// Layer 1 combos: structure

	wipe = SinOsc.kr(0.1).range(0.1, 0.9);
	// wipe = Lag.kr(TRand.kr(0.0, 1.0, Impulse.kr(0.2)), 1.0);
	trig = Impulse.kr(SinOsc.kr(0.1).range(1, 10));


	chain = PV_RandComb(chain, wipe, trig);
	chain = PV_BrickWall(chain);

	sig = IFFT(chain);

	Out.ar(0, sig.dup * amp);
}).add;
)

x = Synth(\layer0_struct0, [\bufnum, b, \amp, 0.3]);
x.free;





// Acheinu
(
SynthDef(\layer0_struct1, {
	arg bufnum, fftSize = 1024, amp = 0.3;

	var in, chain, dry, fx;
	var wipe, trig;
	var sig;

	// Audio input
	in = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum));


	// FFT
	chain = FFT(LocalBuf(fftSize), in);


	// Layer 1 combos: structure

	wipe = SinOsc.kr(0.1).range(0.1, 0.9);
	// wipe = Lag.kr(TRand.kr(0.0, 1.0, Impulse.kr(0.2)), 1.0);
	trig = Impulse.kr(SinOsc.kr(0.1).range(1, 10));


	chain = PV_RandComb(chain, wipe, trig);
	chain = PV_BinShift(chain);

	sig = IFFT(chain);

	Out.ar(0, sig.dup * amp);
}).add;
)


(
SynthDef(\layer0_struct2, {
	arg bufnum, fftSize = 1024, amp = 0.3;

	var in, chain, dry, fx;
	var wipe, trig;
	var sig;

	// Audio input
	in = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum));


	// FFT
	chain = FFT(LocalBuf(fftSize), in);


	// Layer 1 combos: structure

	wipe = SinOsc.kr(0.1).range(0.1, 0.9);
	// wipe = Lag.kr(TRand.kr(0.0, 1.0, Impulse.kr(0.2)), 1.0);
	trig = Impulse.kr(SinOsc.kr(0.1).range(1, 10));



	chain = PV_MagFreeze(chain);
	chain = PV_BrickWall(chain);

	sig = IFFT(chain);

	Out.ar(0, sig.dup * amp);
}).add;
)


(
SynthDef(\layer0_struct3, {
	arg bufnum, fftSize = 1024, amp = 0.3;

	var in, chain, dry, fx;
	var wipe, trig;
	var sig;

	// Audio input
	in = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum));


	// FFT
	chain = FFT(LocalBuf(fftSize), in);


	// Layer 1 combos: structure

	wipe = SinOsc.kr(0.1).range(0.1, 0.9);
	// wipe = Lag.kr(TRand.kr(0.0, 1.0, Impulse.kr(0.2)), 1.0);
	trig = Impulse.kr(SinOsc.kr(0.1).range(1, 10));



	chain = PV_MagAbove(chain);
	chain = PV_MagSmooth(chain);

	sig = IFFT(chain);

	Out.ar(0, sig.dup * amp);
}).add;
)



(
SynthDef(\layer0_struct4, {
	arg bufnum, fftSize = 1024, amp = 0.3;

	var in, chain, dry, fx;
	var wipe, trig;
	var sig;

	// Audio input
	in = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum));


	// FFT
	chain = FFT(LocalBuf(fftSize), in);


	// Layer 1 combos: structure

	wipe = SinOsc.kr(0.1).range(0.1, 0.9);
	// wipe = Lag.kr(TRand.kr(0.0, 1.0, Impulse.kr(0.2)), 1.0);
	trig = Impulse.kr(SinOsc.kr(0.1).range(1, 10));

	chain = PV_PhaseShift90(chain);
	chain = PV_Diffuser(chain, trig);

	sig = IFFT(chain);

	Out.ar(0, sig.dup * amp);
}).add;
)



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

(
SynthDef(\layer1_textur0, {
	arg bufnum, fftSize = 1024, amp = 0.3;

	var in, chain, dry, fx;
	var wipe, trig;
	var sig;

	// Audio input
	in = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum));


	// FFT
	chain = FFT(LocalBuf(fftSize), in);


	// Layer 1 combos: structure

	wipe = SinOsc.kr(0.1).range(0.1, 0.9);
	// wipe = Lag.kr(TRand.kr(0.0, 1.0, Impulse.kr(0.2)), 1.0);
	trig = Impulse.kr(SinOsc.kr(0.1).range(1, 10));

	chain = PV_RandComb(chain);
	chain = PV_BinScramble(chain);
	chain = PV_BinWipe(chain, chain);

	sig = IFFT(chain);

	Out.ar(0, sig.dup * amp);
}).add;
)

(
SynthDef(\layer1_textur1, {
	arg bufnum, fftSize = 1024, amp = 0.3;

	var in, chain, dry, fx;
	var wipe, trig;
	var sig;

	// Audio input
	in = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum));


	// FFT
	chain = FFT(LocalBuf(fftSize), in);


	// Layer 1 combos: structure

	wipe = SinOsc.kr(0.1).range(0.1, 0.9);
	// wipe = Lag.kr(TRand.kr(0.0, 1.0, Impulse.kr(0.2)), 1.0);
	trig = Impulse.kr(SinOsc.kr(0.1).range(1, 10));


	chain = PV_RandComb(chain);
	chain = PV_BinShift(chain);
	chain = PV_Diffuser(chain);


	sig = IFFT(chain);

	Out.ar(0, sig.dup * amp);
}).add;
)

(
SynthDef(\layer1_textur2, {
	arg bufnum, fftSize = 1024, amp = 0.3;

	var in, chain, dry, fx;
	var wipe, trig;
	var sig;

	// Audio input
	in = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum));


	// FFT
	chain = FFT(LocalBuf(fftSize), in);


	// Layer 1 combos: structure

	wipe = SinOsc.kr(0.1).range(0.1, 0.9);
	// wipe = Lag.kr(TRand.kr(0.0, 1.0, Impulse.kr(0.2)), 1.0);
	trig = Impulse.kr(SinOsc.kr(0.1).range(1, 10));


	chain = PV_MagSquared(chain);
	chain = PV_RectComb(chain);


	sig = IFFT(chain);

	Out.ar(0, sig.dup * amp);
}).add;
)


(
SynthDef(\layer1_textur3, {
	arg bufnum, fftSize = 1024, amp = 0.3;

	var in, chain, dry, fx;
	var wipe, trig;
	var sig;

	// Audio input
	in = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum));


	// FFT
	chain = FFT(LocalBuf(fftSize), in);


	// Layer 1 combos: structure

	wipe = SinOsc.kr(0.1).range(0.1, 0.9);
	// wipe = Lag.kr(TRand.kr(0.0, 1.0, Impulse.kr(0.2)), 1.0);
	trig = Impulse.kr(SinOsc.kr(0.1).range(1, 10));


	chain = PV_MagFreeze(chain);
	chain = PV_BinWipe(chain, chain);


	sig = IFFT(chain);

	Out.ar(0, sig.dup * amp);
}).add;
)


(
SynthDef(\layer1_textur4, {
	arg bufnum, fftSize = 1024, amp = 0.3;

	var in, chain, dry, fx;
	var wipe, trig;
	var sig;

	// Audio input
	in = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum));


	// FFT
	chain = FFT(LocalBuf(fftSize), in);


	// Layer 1 combos: structure

	wipe = SinOsc.kr(0.1).range(0.1, 0.9);
	// wipe = Lag.kr(TRand.kr(0.0, 1.0, Impulse.kr(0.2)), 1.0);
	trig = Impulse.kr(SinOsc.kr(0.1).range(1, 10));


	chain = PV_BrickWall(chain);
	chain = PV_MagSmooth(chain);


	sig = IFFT(chain);

	Out.ar(0, sig.dup * amp);
}).add;
)
