// TODO


(
5.do { |i|
	SynthDef(("layer0_struct" ++ i).asSymbol, {
		arg buf, out, fftSize = 1024, amp = 0.3;

		var in, chain, sig, wipe, trig, interp, stretch, shift, threshold, factor, freeze, lfo;
		var wipeFreq = 0.2;
		var wipeDepth = 1;

		// Sample playback
		in = PlayBuf.ar(1, buf, BufRateScale.kr(buf), loop: 1);

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

		// Unique spectral processing per struct
		switch(i,
			0, {
				wipe = SinOsc.kr(wipeFreq).range(wipeDepth, 0.85);
				trig = Impulse.kr(SinOsc.kr(0.1).range(1, 10));

				chain = PV_RandComb(chain, wipe, trig);
				chain = PV_BrickWall(chain, wipe);
			},
			1, {
				wipe = SinOsc.kr(wipeFreq).range(wipeDepth, 0.85);
				trig = 0.0;

				stretch = 1.0;
				shift = 0.0;
				interp = 0;

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

			},
			2, {
				freeze = 0.0;
				wipe = 0.0;

				chain = PV_MagFreeze(chain, freeze);
				chain = PV_BrickWall(chain, wipe);
			},
			3, {
				threshold = 0.0;
				factor = 0.1;

				chain = PV_MagAbove(chain, threshold);
				chain = PV_MagSmooth(chain, factor);
			},
			4, {
				trig = 0.0;

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

		sig = IFFT(chain);

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





(
5.do { |i|
	SynthDef(("layer0_textu" ++ i).asSymbol, {
		arg buf, out, fftSize = 1024, amp = 0.3;

		var in, chain, sig, wipe, trig;

		// Sample playback
		in = PlayBuf.ar(1, buf, BufRateScale.kr(buf), loop: 1);

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

		// Unique spectral processing per struct
		switch(i,
			0, {
				chain = PV_RandComb(chain);
				chain = PV_BinScramble(chain);
				chain = PV_BinWipe(chain, chain);
			},
			1, {
				chain = PV_RandComb(chain);
				chain = PV_BinShift(chain);
				chain = PV_Diffuser(chain);
			},
			2, {
				chain = PV_MagSquared(chain);
				chain = PV_RectComb(chain);
			},
			3, {
				chain = PV_MagFreeze(chain);
				chain = PV_BinWipe(chain, chain);
			},
			4, {
				chain = PV_BrickWall(chain);
				chain = PV_MagSmooth(chain);
			}
		);

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




/*# Effects
Verb	CC12	convolution reverb
Comb	CC13	comb filter
Fold	CC14	wave folding
Sply	CC15	splay*/
