{arg s, pracmode, pracpath;
/* 
a re-working of code for Organon Sostenuto... using ProcEvents and ProcMod.

TO DO: need to scale all instrument inputs

*/

var fluteev, flutegui, celloev, cellogui, bassoonev, bassoongui, bassev, bassgui,
screenBounds, sbWidth, sbHeight;
var flutein, celloin, bassoonin, bassin, flutepedal, cellopedal, bassoonpedal, basspedal;
var flutebus, cellobus, bassoonbus, bassbus, bfbus;
var cond, bufdur;
var proc1a, proc1b, proc2a, proc2b, proc3a, proc4, proc5, proc5a, proc6, proc7, proc7a, proc7c,  
proc8, proc8a, proc8b, proc9, proc10, proc10a, proc11;
var flutebuf, fluteinit, flutekill, cellobuf, celloinit, cellokill, bassoonbuf, bassooninit, 
bassoonkill, bassbuf, bassinit, basskill, flutenode, cellonode, bassoonnode, bassnode;
var warp1, warp2, warp3, warp4, warp5, warp6, specbuf, specbufsize;
var c4, d4, ds4, accord, c4bus, d4bus, ds4bus, accordbus, atsbus, proc7cbus, genwarpbus;
var getval, pevents;
var init = true, initfun, killfun, kill;
var sinenv;

/* some helper functions */

/* getval - object, time - passes in an object, and decides if it is an Envelope, number, function,
 and grabs out a value */
 
getval = {arg obj, time;
	obj.isKindOf(Env).if({
		obj[time]
		}, {
		obj.(time)
		})
	};
	
s = s ? Server.internal.boot;

s.newAllocators;

cond = Condition.new;

/* information for the buffer where all 4 instruments are recorded */

bufdur = 15; /* in minutes for the buffer */

/* inits and kills */

initfun = {
	init = false;
	s.sendBundle(0.1, 
		[\s_new, \bfdecode, s.nextNodeID, 1, 0, \inbus, bfbus])
	};
	
fluteinit = ProcMod(1, 1, \fluteinit)
	.function_({
		s.sendBundle(0.1, 
			[\s_new, \route, flutenode = s.nextNodeID, 0, 0, \inbus, flutein, 
				\outbus, flutebus, \scale, 1],
			[\s_new, \recbuf, s.nextNodeID, 3, flutenode, \inbus, flutebus,
				\buffer, flutebuf]);
		init.if({initfun.()});
		});

flutekill = ProcMod(nil, 1, \flutekill)
	.function_({
		"Flute Buffer freed".postln;
		s.sendMsg(\b_free, flutebuf);
		killfun.value;
		});

celloinit = ProcMod(1, 1, \celloinit)
	.function_({
		s.sendBundle(0.1, 
			[\s_new, \route, cellonode = s.nextNodeID, 0, 0, \inbus, celloin, 
				\outbus, cellobus, \scale, 1],
			[\s_new, \recbuf, s.nextNodeID, 3, cellonode, \inbus, cellobus,
				\buffer, cellobuf]);
		init.if({initfun.()});
		});

cellokill = ProcMod(nil, 1, \cellokill)
	.function_({
		"Cello Buffer freed".postln;
		s.sendMsg(\b_free, cellobuf);
		killfun.value;
		});
		
bassooninit = ProcMod(1, 1, \bassooninit)
	.function_({
		s.sendBundle(0.1, 
			[\s_new, \route, bassoonnode = s.nextNodeID, 0, 0, \inbus, bassoonin, 
				\outbus, bassoonbus, \scale, 1],
			[\s_new, \recbuf, s.nextNodeID, 3, bassoonnode, \inbus, bassoonbus,
				\buffer, bassoonbuf]);
		init.if({initfun.()});
		});

bassoonkill = ProcMod(nil, 1, \bassoonkill)
	.function_({
		"Bassoon Buffer freed".postln;
		s.sendMsg(\b_free, bassoonbuf);
		killfun.value;
		});
		
bassinit = ProcMod(1, 1, \bassinit)
	.function_({
		"Bassbus".postln;
		s.sendBundle(0.1, 
			[\s_new, \route, bassnode = s.nextNodeID, 0, 0, \inbus, bassin, 
				\outbus, bassbus.postln, \scale, 1],
			[\s_new, \recbuf, s.nextNodeID, 3, bassnode, \inbus, bassbus,
				\buffer, bassbuf]);
		init.if({initfun.()});
		});

basskill = ProcMod(nil, 1, \basskill)
	.function_({
		"Bass Buffer freed".postln;
		s.sendMsg(\b_free, bassbuf);
		/* bass will probably kill all */
		killfun.value;
		});		

kill = true;

killfun = {
	kill.if({
		kill = false;
		/* free the ATS buffers here */
		[c4, d4, ds4, accord].do({arg me; me.freeBuffer});
		/* free the warp bufs */
		[warp1, warp2, warp3, warp4, warp5, warp6].do({arg me; s.sendMsg(\b_free, me)});
		/* specbufs */
		100.do({arg i;
			s.sendMsg(\b_free, specbuf + i)
			});
		})
	};
/* the processes! */

proc1a = {arg id, procenv, amp = 1, bufnum, inbus, prelevel = 1, pshiftmix = 1;
	var proc;
	proc = ProcMod(procenv, amp, id, server: s)
		.function_({
			s.sendBundle(0.1, [\s_new, \warpoverlap, s.nextNodeID, 0, proc.group,
				\bufnum, bufnum, \inbus, inbus, \outbus, bfbus, \procenv, proc.envbus,
				\prelevel, prelevel, \pshiftmix, pshiftmix])
			})
	};

proc1b = {arg id, procenv, amp = 1, bufnum;
	var proc;
	proc = ProcMod(procenv, amp, id, server: s)
		.function_({
			s.sendBundle(0.1, [\s_new, \warpgrains, s.nextNodeID, 0, proc.group, 
				\bufnum, bufnum, \outbus, bfbus, \procenv, proc.envbus])
			})
	};

/* this one may need some checking!!! pevent (froom the pevents array) is passed in rather 
then eventbuf */
/* example: [proc2a.(\fl3, Env([0, 1, 0], [2, 2], \sin, 1), 1, flutebuf, [65, 60, 63, 60] + 12,
			0.5, [-0.25, 0.25, 0.75, 1.25] * pi, 0.2, 2.5, 2, \flute, \fl3), nil],

if the id is the current event, it can be left nil			
 */
proc2a = {arg id, procenv, amp = 1, buffer, freq, rand, loc, rq = 0.1, windowsize = 1,
		overlaps = 2, peventidx;
	var proc, freqsize, pevent;
	freqsize = freq.size;
	loc = loc.asArray;
	freq = freq.asArray.midicps; /* was freq.midicps.asArray */
	proc = ProcMod(procenv, amp, id, server: s)
		.function_(
			Task({
				pevent = pevents[peventidx];
				inf.do({arg i;
					var dur, overlapval, proctime, curtime, thisfreq, thisrand;
					proctime = proc.now;
					curtime = pevent.now;
					thisrand = getval.(rand, proctime);
					dur = getval.(windowsize, proctime);
					overlapval = getval.(overlaps, proctime);
					thisfreq = freq[i%freqsize] * (1.0 + thisrand.rand2);
					thisfreq.postln;
					s.sendBundle(0.1, [\s_new, \scrapes, s.nextNodeID, 0, proc.group,
						\procenv, proc.envbus, \dur, dur, \freq, thisfreq, 
						\loc, loc[i % loc.size], \buffer, buffer, \rq, getval.(rq, proctime),
						\time, curtime - 0.1, \rate, 0.5.rrand(0.25), \outbus, 0]);
					(dur / overlapval).wait;
					})
				})
			)
		};

/* can probably turn eventbuf into the time stamp that represents a ProcEvent.start(id) ...
probably need to pass in two values peventidx and the event's id

eventbuf replaced by peventidx and peventid
*/
/* change to peventidx structure! */
proc2b = {arg id, procenv, amp = 1, rq = 0.1, windowsize = 1, overlaps = 2, buffer, 		deltime, peventidx;
	var proc, pevent, freqs;
	freqs = [50, 150, 250, 350, 450, 570, 700, 840, 1000, 1170, 1370, 1600, 1850, 
		2150, 2500, 2900, 3400, 4000, 4800, 5800, 7000, 8500, 10500, 13500 ];
	proc = ProcMod(procenv, amp, id, server: s)
		.function_(
			Task({
				var curtime, proctime, buftime, dur, del, thisfreq, thisoverlap, thisrq;				pevent = pevents[peventidx];
				inf.do({arg i;
					/* event time within ProcMod */
					proctime = proc.now;
					curtime = pevent.now;
					dur = getval.(windowsize, proctime);
					del = getval.(deltime, proctime);
					thisoverlap = getval.(overlaps, proctime);
					thisfreq = freqs.choose * (0.9.rrand(1.1));
					thisrq = getval.(rq, proctime);
					s.sendBundle(0.1, 
						[\s_new, \specdelay, s.nextNodeID, 0, proc.group, 
							\procenv, proc.envbus, \dur, dur, \freq, thisfreq, 
							\buffer, buffer, \rq, thisrq, \time, pevent.now - 0.1, 
							\stretchfactor, 1.2.rrand(2.0), \outbus, bfbus, \deltime, del]);
					(dur / thisoverlap).wait;
					})
				})
			)

	};
	
proc3a = {arg id, procenv, amp = 1, inbus, freqenvs, outbus, outamp = 1.0;
	var proc;
	proc = ProcMod(procenv, amp, id, addAction: 0, target: 1, server: s)
		.function_({
			var busses;
			busses = Array.fill(freqenvs.size, {s.controlBusAllocator.alloc(1)});
			freqenvs.do({arg me, i;
				var thisnode, othernode, thisenv;
				thisenv = me.asArray;
				// this feeds into ats notes... control volume there
				// use amp for BF routing
				s.sendBundle(0.1, 
					[\s_new, \controlenv, thisnode = s.nextNodeID, 0, proc.group,
						\outbus, busses[i]],
					[\n_setn, thisnode, \env, thisenv.size] ++ thisenv,
					[\s_new, \pshift, othernode = s.nextNodeID, 1, proc.group, 
						\procenv, proc.envbus, \inbus, inbus, \outbus1, outbus,
						\outbus2, bfbus, \amp2, outamp],
					[\n_map, othernode, \pshift, busses[i]]);
					});
			proc.data(\busses -> busses);
			});
	};

proc4 = {arg id, procenv, amp = 1, inbus, outbus;
	var proc;
	proc = ProcMod(procenv, amp, id, addAction: 1, target: 1, server: s)
		.function_(
			Task({
				var window, xpos, ypos;
				c4.numPartials.do({arg i;
					s.sendBundle(0.1, 
						[\s_new, \atsnote, s.nextNodeID, 0, proc.group, \inbus, inbus,
							\outbus, c4bus, \atsbuffer, c4.buffer, \atspartial, i, 
							\procenv, proc.envbus])
					});
				d4.numPartials.do({arg i;
					s.sendBundle(0.1, 
						[\s_new, \atsnote, s.nextNodeID, 0, proc.group, \inbus, inbus,
							\outbus, d4bus, \atsbuffer, d4.buffer, \atspartial, i, 
							\procenv, proc.envbus])
					});
				ds4.numPartials.do({arg i;
					s.sendBundle(0.1, 
						[\s_new, \atsnote, s.nextNodeID, 0, proc.group, \inbus, inbus,
							\outbus, ds4bus, \atsbuffer, ds4.buffer, \atspartial, i, 
							\procenv, proc.envbus])
					});
				inf.do({arg i;
					window = [c4bus, d4bus, ds4bus].choose;
					xpos = -2.0.rrand(2.0);
					ypos = -2.0.rrand(2.0);
					s.sendBundle(0.1, 
						[\s_new, \atswindow, s.nextNodeID, 1, proc.group, 
							\procenv, proc.envbus, \inbus, window, \nodedur, 7.reciprocal,
							\xpos, xpos, \ypos, ypos, \outbus, bfbus]);
					7.reciprocal.wait;
					})
				});
			)
	};

/* change to peventidx structure! */
proc5 = {arg id, procenv, amp = 1, buffer, freqbase = 1000, attack = 1, sus = 2, overlaps = 5,
		peventidx;	
	var proc, pevent;
	proc = ProcMod(procenv, amp, id, server: s)
		.function_(
			Task({
				var freqmul, ranenv, attenv, susenv, olenv;
				var waittime, stime, dur, proctime;
				pevent = pevents[peventidx];
				freqmul = [0.25, 0.615, 1.415, 0.75, 0.865];
				ranenv = Env([0, 2], [20]); // gets more random over time
				0.1.wait;
				inf.do({arg i;
					proctime = proc.now;
					dur = (getval.(attack, proctime) * 2) + getval.(sus, proctime);
					waittime = dur / getval.(overlaps, proctime);
					stime = pevent.now - (0.1.rrand(ranenv[proctime]));
					s.sendBundle(0.1, 
						[\s_new, \perc, s.nextNodeID, 0, proc.group, \procenv, proc.envbus,
							\outbus, bfbus, \freqmul, freqmul.wrapAt(i), \freqbase, freqbase,
							\bufnum, buffer, \attack, getval.(attack, proctime), 
							\sus, getval.(sus, proctime), \start, stime]);
					waittime.wait;
					})
				})
			)
	};

/* change to peventidx structure! */
proc5a = {arg id, procenv, amp = 1, buffer, freqbase = 100, attack = 1, sus = 2, overlaps = 5,
		playamp = 1, peventidx;
	var proc, pevent;
	proc = ProcMod(procenv, amp, id, server: s)
		.function_(	
			Task({
				var ranenv, freqmul;
				var waittime, stime, dur, proctime;
				freqmul = [0.25, 0.615, 1.415, 0.75, 0.865];
				ranenv = Env([0, 2], [20]);
				pevent = pevents[peventidx];
				inf.do({arg i;
					proctime = proc.now;
					dur = (getval.(attack, proctime) * 2) + getval.(sus, proctime);
					waittime = dur / getval.(overlaps, proctime);
					stime = pevent.now - 0.0.rrand(ranenv[proctime]);
					s.sendBundle(0.1, 
						[\s_new, \perc, s.nextNodeID, 0, proc.group, \procenv, proc.envbus,
							\outbus, bfbus, \freqmul, freqmul.wrapAt(i), \freqbase, freqbase,
							\bufnum, buffer, \attack, getval.(attack, proctime), 
							\sus, getval.(sus, proctime), \start, stime],
						[\s_new, \playback, s.nextNodeID, 0, proc.group, \procenv, proc.envbus,
							\outbus, bfbus, \buffer, buffer, \starttime, stime, 
							\dur, dur, \amp, getval.(playamp, proctime)]);
					waittime.wait;
				})
			})
		);
	};
		
proc6 = {arg id, procenv, amp = 1, intime = 1, inbus, triglevel = -18;
	var proc;
	proc = ProcMod(procenv, amp, id, server: s)
		.function_({
			inbus.asArray.do({arg me;
				s.sendBundle(0.1, 
					[\s_new, \begslap, s.nextNodeID, 0, proc.group, \procenv, proc.envbus,
						\inbus, me, \triglevel, triglevel.dbamp, \outbus, bfbus, 
						\intime, intime])
					})
				})
	};

// harmonize input of the group
// freqs are midi steps... 5 = p4 etc...
// winsize and overlaps can be numbers or envs
/* change to peventidx structure! */

proc7 = {arg id, procenv, amp = 1, winsize = 1, overlaps = 1, freqs = 0, inbus;
	var proc;
	freqs = freqs.asArray.midiratio;
	proc = ProcMod(procenv, amp, id, server: s)
		.function_(	
			Task({
				var waittime, now, dur;
				inf.do({arg i;
					now = proc.now;
					dur = getval.(winsize, now);
					waittime = dur / getval.(overlaps, now);
					s.sendBundle(0.1, 
						[\s_new, \harmall, s.nextNodeID, 0, proc.group, \procenv, proc.envbus,
							\outbus, bfbus, \inbus, inbus, \dur, dur, 
							\freq1, freqs.wrapAt(i), \freq2, freqs.wrapAt(i+1)]);
					waittime.wait;
					});
				})
			)
	};
	
proc7a = {arg id, procenv, amp, winsize = 1, overlaps = 1, freqs = 0, buffer, peventidx, outbus;
	var proc, pevent;
	proc = ProcMod(procenv, amp, id, server: s)
		.function_(
			Task({
			var proctime, curtime, dur, waittime;
			pevent = pevents[peventidx];
			freqs = freqs.asArray.midiratio;
			inf.do({arg i;
				proctime = proc.now;
				curtime = pevent.now;
				dur = getval.(winsize, proctime);
				waittime = dur / getval.(overlaps, proctime);
				buffer.asArray.do({arg me;
					s.sendBundle(0.1, 
						[\s_new, \warpharm, s.nextNodeID, 0, proc.group, \procenv, proc.envbus,
							\outbus, outbus, \buffer, me, \dur, dur, \freq1, freqs.wrapAt(i),
							\freq2, freqs.wrapAt(i+1), \starttime, curtime - 0.05,
							\warpfac, 0.5.rrand(0.2)])
					});
				waittime.wait;
				})
			})
		)
	};
	
/* proc7b wasn't used! proc7c should use the same idea as above! */
/* warpharmall won't work since each instrument may have different starttimes with their own buffer! */

proc7c = {arg id, procenv, amp, inbus, outbus;
	var proc;
	proc = ProcMod(procenv, amp, id, addAction: 1, target: 1, server: s)
		.function_({
			s.sendBundle(0.1, [\s_new, \whfilts, s.nextNodeID, 0, proc.group, 
				\procenv, proc.envbus, \outbus, outbus, \filtbus, inbus])
			});
		};

/* proc8, 8a should be broken up - a genwarp proc, and a specdelay proc that feeds into it */

/* proc8 is now just the genwarps - always run at the HEAD - outbus is the genwarpbus*/

proc8 = {arg id, procenv, amp, warpbuf, peventidx, outbus;
	var proc;
	proc = ProcMod(procenv, amp, id, addAction: 0, target: 1, server: s)
		.function_({
			var now;
			now = pevents[peventidx].now;
			s.sendMsg(\s_new, \genwarp, s.nextNodeID, 0, proc.group, \procenv, 
				proc.envbus, \buffer, warpbuf, \start, now, \warpfactor, 1.5.rrand(1.0),
				\outbus, outbus);
			});
	};
	
/* proc8a is now just the specdelay - always run at the TAIL */

proc8a = {arg id, procenv, amp, winsize, overlaps, inbus1, inbus2, warpbus;
	var proc;
	proc = ProcMod(procenv, amp, id, addAction: 1, target: 1, server: s)
		.function_(
			Task({
				var dur, waittime, proctime;
				inf.do({arg i;
					proctime = proc.now;
					dur = getval.(winsize, proctime);
					waittime = (dur / getval.(overlaps, proctime));
					s.sendBundle(0.1, [\s_new, \specdelays, s.nextNodeID, 0, proc.group,
						\procenv, proc.envbus, \buffer, specbuf + ((i%4)*25), \outbus, bfbus,
						\inbus1, inbus1, \inbus2, inbus2, \warpbus, warpbus, 
						\rq, 0.2.rrand(0.5), \freqscale, 0.9.rrand(1.1), \dur, dur]);
					waittime.wait;
					})
				})
			)
	};
	
proc8b = {arg id, procenv, amp, inbusstart, warpbus;
	var proc;
	proc = ProcMod(procenv, amp, id, addAction: 1, target: 1, server: s)
		.function_({
			s.sendBundle(0.1, [\s_new, \specdelaysall, s.nextNodeID, 0, proc.group, 
				\procenv, proc.envbus, \buffer, specbuf, \outbus, bfbus, \inbusstart,
				inbusstart, \warpbusstart, warpbus, \rq, 0.5, \amp, amp, \freqscale, 1]);
			})
	};
	
proc9 = {arg id, procenv, amp = 1, inbus, outbus, maxamp = 0.25;
	var proc;
	proc = ProcMod(procenv, amp, id, server: s, lag: 10)
		.function_(
			Task({
				var fptbus, routebus, node1;
				fptbus = s.controlBusAllocator.alloc(1);
				routebus = s.audioBusAllocator.alloc(1);
				s.sendBundle(0.1, 
					[\s_new, \atsringin, node1 = s.nextNodeID, 0, proc.group, \inbus, inbus,
						\outbus, routebus, \fptbus, fptbus],
					[\s_new, \atssum, s.nextNodeID, 1, proc.group, \procenv, proc.envbus,
						\ampin, flutebus, \inbus, accordbus, \outbus, outbus, \maxamp, maxamp]);
				accord.numPartials.do({arg i;
					var thisnode;
					s.sendBundle(0.1, [\s_new, \atsring, thisnode = s.nextNodeID, 3, node1,
						\inbus, routebus, \outbus, accordbus, \atsbuffer, accord.buffer, 
						\atspartial, i, \rantime, 40, \pchoffset, 16])
					});
				})
			);
	};

/* proc9a replaced... all that needs to happen is the amp needs to be change to 2 */

proc10 = {arg id, procenv, amp = 1, inbus, outbus, winsize = 8, overlaps = 4;
	var proc, proctime;
	proc = ProcMod(procenv, amp, id, server: s)
		.function_(
			Task({
				var dur, waittime;
				inf.do({arg i;
					proctime = proc.now;
					dur = getval.(winsize, proctime);
					waittime = dur / getval.(overlaps, proctime);
					s.sendBundle(0.1, 
						[\s_new, \psgliss, s.nextNodeID, 0, proc.group, \procenv, proc.envbus, 
							\inbus, inbus, \outbus, outbus, \dur, dur]);
					waittime.wait;
					});
				})
			)
	};
		
proc10a = {arg id, procenv, amp = 1, inbus, outbus, winsize = 8, overlaps = 4, pshifts = 1;
	var proc, pevent, proctime;
	proc = ProcMod(procenv, amp, id, server: s)
		.function_(
			Task({
				inf.do({arg i;
					var now, dur, waittime;
					proctime = proc.now;
					dur = getval.(winsize, proctime);
					waittime = dur / getval.(overlaps, proctime);
					s.sendBundle(0.1, 
						[\s_new, \psfixed, s.nextNodeID, 0, proc.group, \procenv, proc.envbus, 
							\inbus, inbus, outbus, bfbus, \dur, dur, \ps1, pshifts.wrapAt(i),
							\ps2, pshifts.wrapAt(i + 1)]);
					waittime.wait;
					})
				})
			)
	};

/* vocode past input with current sound 

bufinfo is an array of arrays (of four elements) 
	[bufferid, peventidx, startid, endid]
*/

proc11 = {arg id, procenv, amp = 1, inbus, winsize = 8, overlaps = 8, bufinfo, rate = 1, 
		scaler = 1;
	var proc;
	proc = ProcMod(procenv, amp, id, server: s)
		.function_(
			Task({
				var psbus;
				psbus = s.audioBusAllocator.alloc(1);
				/* start the vocoder at the tail */
				s.sendBundle(0.1, 
					[\s_new, \vocode, s.nextNodeID, 1, proc.group, \procenv, proc.envbus,
						\inbus, inbus, \psbus, psbus, \outbus, bfbus]);
				inf.do({arg i;
					var now, dur, waittime, bufferid, idx, startid, endid, pevent, start, end,
						thistime;
					now = proc.now;
					dur = getval.(winsize, now);
					waittime = dur / getval.(overlaps, now);
					#bufferid, idx, startid, endid = bufinfo.asArray.choose;
					pevent = pevents[idx];
					start = pevent[startid].starttime;
					end = pevent[endid].starttime;
					thistime = start.rrand(end);
					s.sendBundle(0.1, 
						[\s_new, \warpvoc, s.nextNodeID, 0, proc.group, \outbus, psbus,
							\buffer, bufferid, \rate, rate, \scaler, scaler, 
							\buftime, thistime, \dur, dur]);
					waittime.wait;
					})
				})
			)
	};

	
Routine.run({

	s.sync(cond);
			
	/* all instruments will be read in and re-routed out after being scaled */
	
	flutein = s.options.numOutputBusChannels;
	flutebus = s.audioBusAllocator.alloc(1);
	celloin = flutein + 1;
	cellobus = s.audioBusAllocator.alloc(1);
	bassoonin = flutein; // + 2
	bassoonbus = s.audioBusAllocator.alloc(1);
	bassin = flutein + 1; // + 3
	bassbus = s.audioBusAllocator.alloc(1);
	flutepedal = flutein + 4;
	cellopedal = flutein + 5;
	bassoonpedal = flutein + 6;
	basspedal = flutein + 7;
	genwarpbus = s.audioBusAllocator.alloc(1);
	
	/* 4 channels for the BFormat signal */
	
	bfbus = s.audioBusAllocator.alloc(4);
	
	/* allocate memory */
	s.sendMsgSync(cond, \b_alloc, flutebuf = s.bufferAllocator.alloc(1), 
		(bufdur * 60 * s.sampleRate), 1);
	"Flute Buffer Alloc'd".postln;
	s.sendMsgSync(cond, \b_alloc, cellobuf = s.bufferAllocator.alloc(1), 
		(bufdur * 60 * s.sampleRate), 1);
	"Cello Buffer Alloc'd".postln;
	s.sendMsgSync(cond, \b_alloc, bassoonbuf = s.bufferAllocator.alloc(1), 
		(bufdur * 60 * s.sampleRate), 1);
	"Bassoon Buffer Alloc'd".postln;
	s.sendMsgSync(cond, \b_alloc, bassbuf = s.bufferAllocator.alloc(1), 
		(bufdur * 60 * s.sampleRate), 1);
	"Bass Buffer Alloc'd".postln;
	s.sendMsgSync(cond, \b_alloc, warp1 = s.bufferAllocator.alloc(1), 
		s.sampleRate.nextPowerOfTwo, 1);
	s.sendMsgSync(cond, \b_alloc, warp2 = s.bufferAllocator.alloc(1), 
		s.sampleRate.nextPowerOfTwo, 1);
	s.sendMsgSync(cond, \b_alloc, warp3 = s.bufferAllocator.alloc(1), 
		s.sampleRate.nextPowerOfTwo, 1);
	s.sendMsgSync(cond, \b_alloc, warp4 = s.bufferAllocator.alloc(1), 
		s.sampleRate.nextPowerOfTwo, 1);
	s.sendMsgSync(cond, \b_alloc, warp5 = s.bufferAllocator.alloc(1), 
		s.sampleRate.nextPowerOfTwo, 1);
	s.sendMsgSync(cond, \b_alloc, warp6 = s.bufferAllocator.alloc(1), 
		s.sampleRate.nextPowerOfTwo, 1);
		
	/* specbuf is the first buffer for spectral delays */
	specbuf = s.bufferAllocator.alloc(100);
	specbufsize = (1.9 * s.sampleRate).nextPowerOfTwo;
	100.do({arg i;
		s.sendMsgSync(cond, \b_alloc, specbuf + i, specbufsize);
		});
	"Spectral Delay buffers init'd".postln;
		
	/* load the ats files to buffers	*/
	c4 = AtsFile.new("sounds/fluteC4.ats", server: s).loadToBuffer; 
	// 13 partials
	d4 = AtsFile.new("sounds/fluteD4.ats", server: s).loadToBuffer; 
	// 19 partials
	ds4 = AtsFile.new("sounds/fluteDSharp4.ats", server: s).loadToBuffer; 
	// 25 partials	
	accord = AtsFile.new("sounds/accordian.ats", server: s).loadToBuffer;
	
	c4bus = s.audioBusAllocator.alloc(1);
	d4bus = s.audioBusAllocator.alloc(1);
	ds4bus = s.audioBusAllocator.alloc(1);
	accordbus = s.audioBusAllocator.alloc(1);
	atsbus = s.audioBusAllocator.alloc(1);
	proc7cbus = s.audioBusAllocator.alloc(4);
	
	sinenv = Env.asr(1, 1, 1, \sin);
/*  
event in other ProcEvents can be turned of as follows: place this (or somthing similar) into an 
event function:

// turn off \fl3 in fluteev
{fluteev.eventDict[\fl3].release}
*/		
	fluteev = ProcEvents([
/* 0 */		[{"Flute 1".postln}, nil],
/* 1 */		[
				proc1a.(\flute01, sinenv, -6.dbamp, warp1, flutebus), 
				nil],
/* 2 */		[
				proc1a.(\flute02, sinenv, -6.dbamp, warp1, flutebus), 
				\flute01],
/* 3 */		[	
				proc1a.(\flute03, sinenv, -6.dbamp, warp1, flutebus), 
				\flute02],
/* 4 */		[
				proc6.(\flute04, Env([0, 1, 0], [1, 10], \sin, 1), -36.dbamp, 4, cellobus,
					-36),
				nil],
/* 5 */		[
				proc1a.(\flute05, sinenv, -6.dbamp, warp1, flutebus), 
				[\flute03, \flute04]],
/* 6 */		[
				proc1a.(\flute06, sinenv, -6.dbamp, warp1, flutebus), 
				\flute05],
/* 7 */		[
				proc1a.(\flute07, sinenv, -6.dbamp, warp1, flutebus), 
				\flute06],
/* 8 */		[	proc1a.(\flute08, Env.asr(1, 1, 15, \sin), -6.dbamp, warp1, flutebus), 
				\flute07],
/* 9 */		[
				[
					{celloev.eventDict[\cello07c].release},
					proc10a.(\flute09, Env([0, 1, 0], [4, 4], \sin, 1), flutebus, bfbus, 6, 3,
						[2, -2, 3, -3].midiratio);
				], 
				\flute08],
/* 10 */		[
				proc10a.(\flute10, Env([0, 1, 0], [4, 1], [\sin, -4], 1), 1, flutebus, bfbus, 
					4, 3, [3, 7, -9, 3, -5, -12, 3, -5, -9, 7].midiratio), 
				\flute09],
/* 11 */		[	
				[
					{celloev.eventDict[\cello07].release},
					{celloev.eventDict[\cello11].release},
					{bassev.eventDict[\bass10].release},
					{bassoonev.eventDict[\bassoon14].release},
					proc6.(\flute11, Env([0, 1, 0], [0.01, 10], \sin, 1), 1, 1, 
						[bassbus, cellobus], -36), 
				],
				\flute10],
/* 12 */		[
				proc2a.(\flute12, Env([0, 1, 0], [2, 6], [\sin, -4], 1), 0.dbamp, flutebuf,
					[65, 60, 63, 60] + 12, 0.5, [-0.25, 0.25, 0.75, 1.25] * pi, 0.2, 2.5, 2,
					\flute), 
				\flute11],
/* 13 */		[
				proc5.(\flute13, Env([0, 1, 0], [4, 2], \sin, 1), 12.dbamp, flutebuf, 1760, 
					1, 2, 3,\flute), 
				\flute12],
/* 14 */		[
				proc5a.(\flute14, Env([0, 1, 0], [2, 10], [\sin, -2], 1), 6.dbamp, flutebuf, 
					1760, 1, Env([3, 1], [20]), Env([2, 2.9], [20]), 
					Env([-18.dbamp, 0.dbamp], [20]), \flute), 
				\flute13],
/* 15 */		[
				{
					celloev.eventDict[\cello25].release;
					bassoonev.eventDict[\bassoon28].release;
				},
				\flute14],
/* 16 */		[
				[
					proc8a.(\flute16, Env([0, 1, 0], [0.1, 8], [\sin, -4], 1), 1, 6, 2.9,
						flutebus, bassoonbus, genwarpbus),
					proc8.(\flute16a, Env([0, 1, 0], [0.1, 8], [\sin, -4], 1), 1, flutebuf, 
						\flute, genwarpbus),
					proc8.(\flute16b, Env([0, 1, 0], [0.1, 8], [\sin, -4], 1), 1, bassoonbuf,
						\bassoon, genwarpbus)
					],						
				nil],
/* 17 */		[
				[
					proc8a.(\flute17, Env([0, 1, 0], [0.1, 8], [\sin, -4], 1), 1, 6, 2.9,
						flutebus, bassoonbus, genwarpbus),
					proc8.(\flute17a, Env([0, 1, 0], [0.1, 8], [\sin, -4], 1), 1, flutebuf, 
						\flute, genwarpbus),
					proc8.(\flute17b, Env([0, 1, 0], [0.1, 8], [\sin, -4], 1), 1, bassoonbuf,
						\bassoon, genwarpbus)
					], 
				[\flute16, \flute16a, \flute16b]],
/* 18 */		[
				[
					proc8a.(\flute18, Env([0, 1, 0], [0.1, 6], [\sin, -4], 1), 1, 6, 2.9,
						flutebus, bassoonbus, genwarpbus),
					proc8.(\flute18a, Env([0, 1, 0], [0.1, 6], [\sin, -4], 1), 1, flutebuf, 
						\flute, genwarpbus),
					proc8.(\flute18b, Env([0, 1, 0], [0.1, 6], [\sin, -4], 1), 1, bassoonbuf,
						\bassoon, genwarpbus)
					], 
				[\flute17, \flute17a, \flute17b]],
/* 19 */		[nil, [\flute18, \flute18a, \flute18b]],
/* 20 */		[
				[
					proc8a.(\flute20, Env([0, 1, 0], [0.1, 14], [\sin, -4], 1), 1, 6, 2.9,
						flutebus, bassoonbus, genwarpbus),
					proc8.(\flute20a, Env([0, 1, 0], [0.1, 14], [\sin, -4], 1), 1, flutebuf, 
						\flute, genwarpbus),
					proc8.(\flute20b, Env([0, 1, 0], [0.1, 14], [\sin, -4], 1), 1, bassoonbuf,
						\bassoon, genwarpbus)
					],						
				nil],
/* 21 */		[nil, [\flute20, \flute20a, \flute20b]],
/* 22 */		[
				[
					{bassev.eventDict[\bass23].release},
					proc7a.value(\flute22, Env([0, 1, 0], [0.1, 2], \sin, 1), 1,
						5, 2, [5, 3, 7, 3, 7, 5, 3, 12, 7, 3], flutebuf, \flute, bfbus)
					],
				nil],
/* 23 */		[
				[	
					{bassoonev.eventDict[\bassoon30].release},
					proc8a.(\flute23, Env([0, 1, 0], [0.1, 5], [\sin, -4], 1), 1, 6, 2.9,
						flutebus, bassoonbus, genwarpbus),
					proc8.(\flute23a, Env([0, 1, 0], [0.1, 5], [\sin, -4], 1), 1, flutebuf, 
						\flute, genwarpbus),
					proc8.(\flute23b, Env([0, 1, 0], [0.1, 5], [\sin, -4], 1), 1, bassoonbuf,
						\bassoon, genwarpbus),
					proc7a.value(\flute23c, Env([0, 1, 0], [0.1, 2], \sin, 1), 1, 8, 2,
						[5, 3, 7, 3, 7, 5, 3, 12, 7, 3], cellobuf, \cello, bfbus),
					proc7a.value(\flute23d, Env([0, 1, 0], [0.1, 2], \sin, 1), 1, 8, 2,
						[5, 3, 7, 3, 7, 5, 3, 12, 7, 3], bassbuf, \bass, bfbus)						
					], 
				\flute22],
/* 24 */		[nil, [\flute23, \flute23a, \flute23b]],
/* 25 */		[
				[					
					proc8a.(\flute25, Env([0, 1, 0], [0.1, 14], [\sin, -4], 1), 1, 6, 2.9,
						flutebus, bassoonbus, genwarpbus),
					proc8.(\flute25a, Env([0, 1, 0], [0.1, 14], [\sin, -4], 1), 1, flutebuf, 
						\flute, genwarpbus),
					proc8.(\flute25b, Env([0, 1, 0], [0.1, 14], [\sin, -4], 1), 1, bassoonbuf,
						\bassoon, genwarpbus),
				], 
				nil],
/* 26 */		[nil, [\flute23c, \flute23d]],
/* 27 */		[
				proc1a.(\flute27, sinenv, -6.dbamp, warp5, flutebus), 
				[\flute25, \flute25a, \flute25b]],
/* 28 */		[
				proc1a.(\flute28, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute27],
/* 29 */		[
				proc1a.(\flute29, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute28],
/* 30 */		[
				proc1a.(\flute30, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute29],
/* 31 */		[
				proc1a.(\flute31, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute30],
/* 32 */		[
				proc1a.(\flute32, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute31],
/* 33 */		[
				proc1a.(\flute33, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute32],
/* 34 */		[
				proc1a.(\flute34, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute33],
/* 35 */		[
				proc1a.(\flute35, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute34],
/* 36 */		[
				{
					bassoonev.eventDict[\bassoon37].release;
					bassoonev.eventDict[\bassoon37a].release;
					bassoonev.eventDict[\bassoon37b].release;
				},
				proc1a.(\flute36, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute35],
/* 37 */		[
				proc1a.(\flute37, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute36],
/* 38 */		[
				proc1a.(\flute38, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute37],
/* 39 */		[
				proc1a.(\flute39, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute38],
/* 40 */		[
				proc1a.(\flute40, sinenv, -6.dbamp, warp5, flutebus), 
			 	\flute39],
/* 41 */		[
				proc1a.(\flute41, Env.asr(1, 1, 10, [\sin, -4]), -6.dbamp, warp5, flutebus), 
			 	\flute40],
/* 42 */		[
				[	
					proc7a.(\flute42a, Env([0, 1, 0], [5, 10], [4, -4], 1), 1, 5, 4, [0, 12, 7],
						flutebuf, \flute, bfbus),
					proc7a.(\flute42b, Env([0, 1, 0], [5, 10], [4, -4], 1), 1, 4, 5, 
						[0, 12, 7, -12, 0, 5], bassoonbuf, \bassoon, bfbus),
					{bassoonev.eventDict[\bassoon41].release}, 
				],
				\flute41],
/* 43 */		[
				{
					bassev.eventDict[\bass42].release;
					bassev.eventDict[\bass42a].release;
					bassev.eventDict[\bass42b].release;
					bassev.eventDict[\bass42c].release;
					bassev.eventDict[\bass42d].release}, 
				[\flute42a, \flute42b]]
		],
		1, fluteinit, flutekill, "Flute", s
		);
	
	celloev = ProcEvents([
/* 0 */		[{"Cello 1".postln}, nil],
/* 1 */		[
				[
					proc2b.(\cello01a, Env([0, 1, 0], [2, 12], [\sin, -4], 1),
						12.dbamp, Env([0.5, 0.2], [20]), {8.0.rrand(4.0)}, 4, cellobuf,
						{0.1.rrand(1.0)}, \cello),
					proc2b.(\cello01b, Env([0, 1, 0], [2, 12], [\sin, -4], 1),
						12.dbamp, Env([0.5, 0.2], [20]), {5.0.rrand(3.0)}, 3, bassbuf,
						{0.1.rrand(1.0)}, \bass),
					{bassev.eventDict[\bass01].release}
				],
				nil],
/* 2 */		[nil, nil],
/* 3 */		[	
				proc6.(\cello03, Env([0, 1, 0], [0.01, 10], \sin, 1), -24.dbamp, 4, cellobus,
					-36), 
				[\cello01a, \cello01b]
				],
/* 4 */		[nil, \cello03],
/* 5 */		[
				proc2a.(\cello05, Env([0, 1, 0], [2, 12], [\sin, -4], 1), 0.dbamp, cellobuf,
					[65, 60, 63, 60] + 48, Env([0.5, 0], [5]), [-0.25, 0.25, 0.75, 1.25] * pi, 
					Env([0.2, 0.02], [5]), 2.5, 2, \cello),
				nil],
/* 6 */		[
				[	/* proc1b shuts itself off */
					proc1b.(\cello06a, Env([0, 1, 0], [15, 10], \sin), 1, warp1),
					proc1b.(\cello06b, Env([0, 1, 0], [15, 10], \sin), 1, warp3),
					proc4.(\cello06c, Env([0, 1, 0], [20, 1], \sin, 1), 24.dbamp,
						atsbus, bfbus),
					proc3a.(\cello06d, sinenv, 1, cellobus, 
						[Env([4, 3], [20]), Env([3, 2], [20])], atsbus, 1.0),
					{
						fluteev.eventDict[\flute08].release; 
						bassoonev.eventDict[\bassoon09].release;
					}
				], 
				\cello05],
/* 7 */		[
				[
					proc9.(\cello07, Env([0, 1, 1, 0], [30, 1, 1], [4, -10], 1), -6.dbamp,
						cellobus, bfbus, 0.5), 
					proc10.(\cello07a, Env([0, 1, 0], [1, 4], \sin, 1), 6.dbamp, cellobus,
						bfbus, 8, 4),
					proc10.(\cello07b, Env([0, 1, 0], [1, 4], \sin, 1), 6.dbamp, bassbus, 
						bfbus, 7, 4),
					proc10a.(\cello07c, Env([0, 1, 0], [10, 4], [4, \sin], 1), 6.dbamp, 
						flutebus, bfbus, 8, 3, [3, 5, -7, 3, -12, 7, 3, 12].midiratio),
					proc10a.(\cello07d, Env([0, 1, 0], [10, 4], [4, \sin], 1), 6.dbamp, 
						bassoonbus, bfbus, 8, 3, [3, 5, -7, 3, -12, 7, 3, 12].midiratio)				],
				[\cello06c, \cello06d]],
/* 8 */		[
				proc10.(\cello08, Env([0, 1, 0], [4, 4], \sin, 1), 6.dbamp, cellobus, bfbus,
					6, 4), 
				\cello07a],
/* 9 */		[
				proc10.(\cello09, Env([0, 1, 0], [4, 4], \sin, 1), 6.dbamp, cellobus, bfbus,
					4, 4), 
				[\cello08, \cello7c, \cello7d, \cello07b]],
/* 10 */		[
				proc10.(\cello10, Env([0, 1, 0], [4, 4], \sin, 1), 6.dbamp, cellobus, bfbus,
					2.5, 5), 
				\cello09],
/* 11 */		[
				proc10.(\cello11, Env([0, 1, 0], [4, 1], \sin, 1), 6.dbamp, cellobus, bfbus,
					1.5, 4), 
				\cello10],
/* 12 */		[
				[
					proc7a.(\cello12, Env([0, 1, 0], [2, 3], [\sin, -4], 1), 3.dbamp,
						4, 3, [-5, 3, -7, 5, 3], cellobuf, \cello, bfbus),
					{fluteev.eventDict[\flute11].release}, 
				],
				[\cello11, \cello07]],
/* 13 */		[
				proc1a.(\cello13, sinenv, -6.dbamp, warp2, cellobus),
				\cello12],
/* 14 */		[
				proc1a.(\cello14, sinenv, -6.dbamp, warp2, cellobus),
				\cello13],
/* 15 */		[
				proc1a.(\cello15, sinenv, -6.dbamp, warp2, cellobus),
				\cello14],
/* 16 */		[
				proc1a.(\cello16, sinenv, -6.dbamp, warp2, cellobus),
				\cello15],
/* 17 */		[
				proc1a.(\cello17, sinenv, -6.dbamp, warp2, cellobus),
				\cello16],
/* 18 */		[
				proc1a.(\cello18, sinenv, -6.dbamp, warp2, cellobus),
				\cello17],
/* 19 */		[
				proc1a.(\cello19, sinenv, -6.dbamp, warp2, cellobus),
				\cello18],
/* 20 */		[nil, nil],
/* 21 */		[nil, nil],
/* 22 */		[
				{fluteev.eventArray[\flute12].release},
				proc2a.(\cello22, Env([0, 1, 0], [6, 0.2], [\sin, -4], 1), 0.dbamp, cellobuf,
					[65, 60, 63, 60] + 12, 0.5, [-0.25, 0.25, 0.75, 1.25] * pi, 0.2, 2.5, 2,
					\cello), 
				nil],
/* 23 */		[
				proc1a.(\cello23, sinenv, -6.dbamp, warp2, cellobus), 
				[\cello19, \cello22]],
/* 24 */		[
				proc1a.(\cello24, sinenv, -6.dbamp, warp2, cellobus), 
				\cello23],
/* 25 */		[
				proc1a.(\cello25, Env.asr(1, 1, 10, [\sin, -4]), -6.dbamp, warp2, cellobus), 
				\cello24],
/* 26 */		[
				[
					proc7a.(\cello26a, Env([0, 1, 0], [0.1, 4], [\sin, -10], 1), 1,
						8, 2, [5, 3, 7, 3, 7, 5, 3, 12, 7, 3], cellobuf, \cello, bfbus),
					proc7a.(\cello26b, Env([0, 1, 0], [0.1, 4], [\sin, -10], 1), 1,
						8, 2, [5, 3, 7, 3, 7, 5, 3, 12, 7, 3], bassbuf, \bass, bfbus)				], 
				\cello25],
/* 27 */		[
				proc2b.(\cello27, Env([0, 1, 0], [0.1, 12], [\sin, -4], 1),
					1, 0.05, 2, 4, cellobuf, 0.1, \cello), 
				[\cello26a, \cello26b]],
/* 28 */		[nil, \cello27],
/* 29 */		[	{
					fluteev.eventDict[\flute25].release;
					fluteev.eventDict[\flute25a].release;					fluteev.eventDict[\flute25a].release;				},
				proc7a.(\cello29, Env([0, 1, 0], [2, 2], \sin, 1), 1, 8, 2, 
					[5, 3, 7, 3, 7, 5, 3, 12, 7, 3], cellobuf, \cello, bfbus), 
				nil],
/* 30 */		[nil, \cello29],
/* 31 */		[
				[
					proc2b.(\cello31a, Env([0, 1, 0], [0.1, 15], [\sin, -4], 1),
						6.dbamp, Env([0.2, 0.05], [5]), 3, 5, bassbuf, 0.1, \bass), 
					proc2b.(\cello31b, Env([0, 1, 0], [0.1, 15], [\sin, -4], 1),
						6.dbamp, Env([0.2, 0.05], [5]), 4, 4, cellobuf, 0.1, \cello)					],
				nil],
/* 32 */		[nil, [\cello31a, \cello31b]],
/* 33 */		[
				[
					proc7a.(\cello33a, Env([0, 1, 0], [0.1, 1], \sin, 1), 1, 4, 2,
						[12, 3, 7, 15], cellobuf, \cello, bfbus),
					proc7a.(\cello33b, Env([0, 1, 0], [0.1, 1], \sin, 1), 1, 4, 2,
						[12, 3, 7, 15], bassbuf, \bass, bfbus)
				], 
				nil],
/* 34 */		[
				proc11.(\cello34, Env([0, 1, 0], [1, 4], [\sin, -2], 1), 18.dbamp, cellobus,
					8, 4, [[flutebuf, \flute, \flute05, \flute08], 
						[flutebuf, \flute, \flute09, \flute11], 
						[cellobuf, \cello, \cello12, \cello14],
						[bassbuf, \bass, \bass14, \bass16],
						[flutebuf, \flute, \flute25, \flute26],
						[bassoonbuf, \bassoon, \bassoon06, \bassoon10]
					], 2),
				[\cello33a, \cello33b]],
/* 35 */		[
				[
					{bassev.eventArray[\bass34].release},
					proc7a.(\cello35a, Env([0, 1, 0], [0.1, 1], \sin, 1), 1, 4, 2,
						[12, 3, 7, 15], cellobuf, \cello, bfbus),
					proc7a.(\cello35b, Env([0, 1, 0], [0.1, 1], \sin, 1), 1, 5, 2,
						[12, 3, 7, 15], bassbuf, \bass, bfbus)
				
				], 
				\cello34],
/* 36 */		[
				proc2b.(\cello36, Env([0, 1, 0], [0.1, 1], \sin, 1),
					6.dbamp, 0.05, 4, 5, cellobuf, 0.1, \cello), 
				[\cello35a, \cello35b]
				],
/* 37 */		[nil, \cello36],
/* 38 */		[
				proc11.(\cello38, Env([0, 1, 0], [1, 4], [\sin, -2], 1), 18.dbamp, cellobus,
					4, 2.9, [[flutebuf, \flute, \flute05, \flute08], 
						[flutebuf, \flute, \flute09, \flute11], 
						[cellobuf, \cello, \cello12, \cello14],
						[bassbuf, \bass, \bass14, \bass16],
						[flutebuf, \flute, \flute25, \flute26],
						[bassoonbuf, \bassoon, \bassoon06, \bassoon10]
					], 2), 
				nil],
/* 39 */		[
				proc7a.(\cello39, Env([0, 1, 0], [0.1, 1], \sin, 1), 1, 5, 2, [12, 3, 7, 15],
					cellobuf, \cello, bfbus), 
				\cello38],
/* 40 */		[	{bassev.eventDict[\bass36].release}, 
				\cello39],
/* 41 */		[
				proc7a.(\cello41, Env([0, 1, 0], [0.1, 1], \sin, 1), 1, 8, 2, [12, 3, 7, 15],
					cellobuf, \cello, bfbus), 
				nil],
/* 42 */		[
				proc7a.(\cello42, Env([0, 1, 0], [5, 10], [4, -4], 1), 1, 4, 5, 
					[0, 12, 7, -12, 0, -5], cellobuf, \cello, bfbus), 
				\cello41],
/* 43 */		[nil, \cello42]
		],
		1, celloinit, cellokill, "Cello", s
		);
	
	bassoonev = ProcEvents([
			[{"Bassoon 1".postln}, nil],
/* 1 */		[
				proc1a.(\bassoon01, sinenv, -6.dbamp, warp3, bassoonbus), 
				nil],
/* 2 */		[
				proc1a.(\bassoon02, sinenv, -6.dbamp, warp3, bassoonbus), 
				\bassoon01],
/* 3 */		[
				proc1a.(\bassoon03, sinenv, -6.dbamp, warp3, bassoonbus), 
				\bassoon02],
/* 4 */		[
				proc1a.(\bassoon04, sinenv, -6.dbamp, warp3, bassoonbus), 
				\bassoon03],
/* 5 */		[
				proc2a.(\bassoon05, Env([0, 1, 0], [2, 5], [\sin, -4], 1), 0.dbamp, bassoonbuf,
					[65, 60, 63, 60] + 48, Env([0.2, 0], [5]), [-0.25, 0.25, 0.75, 1.25] * pi,
					0.02, 2, 2, \bassoon), 
				nil],
/* 6 */		[nil, \bassoon05],
/* 7 */		[
				proc1a.(\bassoon07, sinenv, -6.dbamp, warp3, bassoonbus), 
				\bassoon04],
/* 8 */		[
				proc1a.(\bassoon08, sinenv, -6.dbamp, warp3, bassoonbus), 
				\bassoon07],
/* 9 */		[
				proc1a.(\bassoon09, sinenv, -6.dbamp, warp3, bassoonbus), 
				\bassoon08],
/* 10 */		[
				proc3a.(\bassoon10, sinenv, 1, bassoonbus, 
					[Env([4, 3], [20]), Env([3, 2], [20])], atsbus, 1.0), 
				\bassoon09],
/* 11 */		[
				[
					{celloev.eventDict[\cello06c].release}, 
					{celloev.eventDict[\cello06d].release},
					{bassev.eventDict[\bass07].release}
				],
				\bassoon10],
/* 12 */		[
				[
					{celloev.eventDict[\cello07d].release},
					proc10a.(\bassoon12, Env([0, 1, 0], [4, 4], \sin, 1), 6.dbamp, bassoonbus,
						bfbus, 6, 3, [5, -5, -7, 7].midiratio)
				], 
				nil],
/* 13 */		[
				proc10a.(\bassoon13, Env([0, 1, 0], [4, 4], \sin, 1), 6.dbamp, bassoonbus,
					bfbus, 5, 3, [3, 5, -7, 3, -12, 7, 3, 12].midiratio),
				\bassoon12],
/* 14 */		[
				proc10a.(\bassoon14, Env([0, 1, 0], [4, 1], [\sin, -4], 1), 6.dbamp,
					bassoonbus, bfbus, 3, 3, [3, 7, -12, 3, -5, 3, 12].midiratio), 
				\bassoon13],
/* 15 */		[
				{celloev.eventDict[\cello07].amp_(0.dbamp)}, 
				nil],
/* 16 */		[
				[
					{fluteev.eventDict[\flute11].release},
					proc1a.(\bassoon16, sinenv, -6.dbamp, warp4, bassoonbus), 
				],
				\bassoon14],
/* 17 */		[
				proc1a.(\bassoon17, sinenv, -6.dbamp, warp4, bassoonbus), 
				\bassoon16],
/* 18 */		[
				proc1a.(\bassoon18, sinenv, -6.dbamp, warp4, bassoonbus), 
				\bassoon17],
/* 19 */		[
				proc1a.(\bassoon19, sinenv, -6.dbamp, warp4, bassoonbus), 
				\bassoon18],
/* 20 */		[
				proc1a.(\bassoon20, sinenv, -6.dbamp, warp4, bassoonbus), 
				\bassoon19],
/* 21 */		[
				proc2a.(\bassoon21, Env([0, 1, 0], [2, 4], [\sin, -4], 1), 0.dbamp, bassoonbuf,
					[65, 60, 63, 60] + 12, 0.5, [-0.25, 0.25, 0.75, 1.25] * pi, 0.2, 2.5, 2,
					\bassoon), 
				nil],
/* 22 */		[	
				proc5.(\bassoon22, Env([0, 1, 0], [4, 4], [\sin, \lin], 1), 12.dbamp, bassoonbuf,
					440, 0.5, 1, 4, \bassoon), 
				\bassoon21],
/* 23 */		[
				proc1a.(\bassoon23, sinenv, -6.dbamp, warp4, bassoonbus), 
				[\bassoon20, \bassoon22]],
/* 24 */		[
				proc1a.(\bassoon24, sinenv, -6.dbamp, warp4, bassoonbus), 
				\bassoon23],
/* 25 */		[
				proc1a.(\bassoon25, sinenv, -6.dbamp, warp4, bassoonbus), 
				\bassoon24],
/* 26 */		[
				proc1a.(\bassoon26, sinenv, -6.dbamp, warp4, bassoonbus), 
				\bassoon25],
/* 27 */		[
				proc1a.(\bassoon27, sinenv, -6.dbamp, warp4, bassoonbus), 
				\bassoon26],
/* 28 */		[
				proc1a.(\bassoon28, Env.asr(1, 1, 8, [\sin, -4]), -6.dbamp, warp4, bassoonbus), 
				\bassoon27],
/* 29 */		[
				{
					fluteev.eventDict[\flute17].release;
					fluteev.eventDict[\flute17a].release;
					fluteev.eventDict[\flute17b].release;
					}, 
				\bassoon28],
/* 30 */		[
				proc7a.(\bassoon30, Env([0, 1, 0], [2, 3], \sin, 1), 1, 5, 2, 
					[5, 3, 7, 3, 7, 5, 3, 12, 7, 3], bassoonbuf, \bassoon, bfbus), 
				nil],
/* 31 */		[
				proc1a.(\bassoon31, sinenv, -6.dbamp, warp6, bassoonbus), 
				\bassoon30],
/* 32 */		[
				proc1a.(\bassoon32, sinenv, -6.dbamp, warp6, bassoonbus), 
				\bassoon31],
/* 33 */		[
				proc1a.(\bassoon33, sinenv, -6.dbamp, warp6, bassoonbus), 
				\bassoon32],
/* 34 */		[
				proc1a.(\bassoon34, sinenv, -6.dbamp, warp6, bassoonbus), 
				\bassoon33],
/* 35 */		[
				proc1a.(\bassoon35, sinenv, -6.dbamp, warp6, bassoonbus), 
				\bassoon34],
/* 36 */		[
				proc1a.(\bassoon36, sinenv, -6.dbamp, warp6, bassoonbus), 
				\bassoon35],
/* 37 */		[
				[					
					proc8a.(\bassoon37, Env([0, 1, 0], [0.1, 8], [\sin, -4], 1), 1, 3, 2.9,
						flutebus, bassoonbus, genwarpbus),
					proc8.(\bassoon37a, Env([0, 1, 0], [0.1, 8], [\sin, -4], 1), 1, flutebuf, 
						\flute, genwarpbus),
					proc8.(\bassoon37b, Env([0, 1, 0], [0.1, 8], [\sin, -4], 1), 1, bassoonbuf,
						\bassoon, genwarpbus),
				], 
				nil],
/* 38 */		[
				proc1a.(\bassoon38, sinenv, -6.dbamp, warp6, bassoonbus), 
				[\bassoon36, \bassoon37, \bassoon37a, \bassoon37b]
				],
/* 39 */		[
				proc1a.(\bassoon39, sinenv, -6.dbamp, warp6, bassoonbus), 
				\bassoon38],
/* 40 */		[
				proc1a.(\bassoon40, sinenv, -6.dbamp, warp6, bassoonbus), 
				\bassoon39],
/* 41 */		[
				proc1a.(\bassoon41, Env.asr(1, 1, 10, [\sin, -4]), -6.dbamp, warp6, bassoonbus), 
				\bassoon40],
/* 42 */		[nil, \bassoon41]
		],
		1, bassooninit, bassoonkill, "Bassoon", s
		);
	
	bassev = ProcEvents([
		[{"Bass 1".postln}, nil],
/* 1 */		[
				proc6.(\bass01, Env([0, 1, 0], [0.01, 10], \sin , 1), 1.41,
					1, [bassbus, cellobus], -18), 
				nil],
/* 2 */		[
				nil, 
				\bass01],
/* 3 */		[
				{celloev.eventDict[\cello01b].release}, 
				nil],
/* 4 */		[
				[
					{fluteev.eventDict[\flute04].release},
					proc6.(\bass04, Env([0, 1, 0], [0.01, 10], \sin, 1), -12.dbamp,
						4, bassbus, -36)
					],
				nil],
/* 5 */		[	
				proc2a.(\bass05, Env([0, 1, 0], [2, 12], [\sin, -4], 1), 0.dbamp, bassbuf,
					[65, 60, 63, 60] + 48, Env([0.5, 0], [20]), [-0.25, 0.25, 0.75, 1.25] * pi,
					Env([0.2, 0.02], [20]), 2, 2, \bass), 
				\bass04],
/* 6 */		[
				proc2b.(\bass06, Env([0, 1, 0], [2, 12], [\sin, -4], 1),
					1, Env([0.5, 0.2], [20]), 5, 3, bassbuf, {0.1.rrand(1.0)}, \bass), 
				nil],
/* 7 */		[
				proc3a.(\bass07, sinenv, 1, bassbus, 
					[Env([4, 3], [5]), Env([3, 2], [5])], atsbus, 1.0), 
				[\bass05, \bass06]],
/* 8 */		[
				[
				{celloev.eventDict[\cello07b].release},
				proc10.(\bass08, Env([0, 1, 0], [4, 4], \sin, 1), 6.dbamp, bassbus, bfbus,
					4, 4)
				],
				\bass07],
/* 9 */		[
				proc10.(\bass09, Env([0, 1, 0], [4, 4], \sin, 1), 6.dbamp, bassbus, bfbus,
					3, 4), 
				\bass08],
/* 10 */		[
				proc10.(\bass10, Env([0, 1, 0], [4, 1], \sin, 1), 6.dbamp, bassbus, bfbus, 
					2, 2),
				\bass09],
/* 11 */		[
				proc2b.(\bass11, Env([0, 1, 0], [2, 12], [\sin, -4], 1),
					6.dbamp, Env([0.5, 0.2], [20]), {5.0.rrand(3.0)}, 3, bassbuf, 
					{0.1.rrand(1.0)}, \bass), 
				\bass10],
/* 12 */		[	nil, \bass11],
/* 13 */		[	/* \bass13 releases itself */
				proc11.(\bass13, Env([0, 1, 1, 0], [1, 2, 14], [\sin, \lin, -2]), 12.dbamp,
					bassbus, 8, 4, [[flutebuf, \flute, \flute09, \flute11]], 2), 
				nil],
/* 14 */		[	
				proc5.(\bass14, Env([0, 1, 0], [4, 10], [\sin, \lin], 1), 12.dbamp, bassbuf,
					880, 1, 2, 3, \bass), 
				nil],
/* 15 */		[nil, \bass14],
/* 16 */		[	
				proc5.(\bass16, Env([0, 1, 0], [4, 4], [\sin, \lin], 1), 12.dbamp, bassbuf,
					880, 1, 2, 3, \bass), 
				nil],
/* 17 */		[nil, \bass16],
/* 18 */		[nil, nil],
/* 19 */		[
				proc5a.(\bass19, Env([0, 1, 0], [2, 10], [\sin, \welch], 1), 12.dbamp, bassbuf, 
					440, 1, Env([3, 2], [20]), Env([2, 2.9], [20]), 
					Env([-18.dbamp, 0.dbamp], [20]), \bass), 
				nil],
/* 20 */		[	
				{
					bassoonev.eventDict[\bassoon28].release;
					fluteev.eventDict[\flute14].release;
					celloev.eventDict[\cello25].release;
				},
				\bass19],
/* 21 */		[
				[
					{
						fluteev.eventDict[\flute16].release;
						fluteev.eventDict[\flute16a].release;
						fluteev.eventDict[\flute16b].release;
					},
					proc7a.(\bass21a, Env([0, 1, 0], [0.1, 5], \sin, 1), 1, 8, 2, 
						[5, 3, 7, 3, 7, 5, 3, 12, 7, 3], cellobuf, \cello, bfbus),
					proc7a.(\bass21b, Env([0, 1, 0], [0.1, 5], \sin, 1), 1, 8, 2, 
						[5, 3, 7, 3, 7, 5, 3, 12, 7, 3], bassbuf, \bass, bfbus)				], 
				nil],
/* 22 */		[nil, [\bass21a, \bass21b]],
/* 23 */		[
				proc2b.(\bass23, Env([0, 1, 0], [0.1, 12], [\sin, -4], 1),
					1, 0.05, 3, 4, bassbuf, 0.1, \bass), 
				[\cello26a, \cello26b]],
/* 24 */		[
				[
					proc7a.(\bass24a, Env([0, 1, 0], [2, 2], \sin, 1), 1, 8, 2, 
						[5, 3, 7, 3, 7, 5, 3, 12, 7, 3], cellobuf, \cello, bfbus),
					proc7a.(\bass24b, Env([0, 1, 0], [2, 2], \sin, 1), 1, 8, 2, 
						[5, 3, 7, 3, 7, 5, 3, 12, 7, 3], bassbuf, \bass, bfbus)
					{
						fluteev.eventDict[\flute23c].release;
						fluteev.eventDict[\flute23d].release
						}
					],
				\bass23],
/* 25 */		[
				proc7a.(\bass25, Env([0, 1, 0], [2, 2], \sin, 1), 1, 7, 2, 
						[5, 3, 7, 3, 7, 5, 3, 12, 7, 3], bassbuf, \bass, bfbus), 
				[\bass24a, \bass24b]],
/* 26 */		[nil, \bass25],
/* 27 */		[
				[					
					proc8b.(\bass27, Env([0, 1, 0], [0.1, 3], [\sin, -4], 1), -6.dbamp,
						flutebus, genwarpbus),
					proc8.(\bass27a, Env([0, 1, 0], [0.1, 3], [\sin, -4], 1), 1, flutebuf, 
						\flute, genwarpbus),
					proc8.(\bass27b, Env([0, 1, 0], [0.1, 3], [\sin, -4], 1), 1, cellobuf, 
						\cello, genwarpbus),
					proc8.(\bass27c, Env([0, 1, 0], [0.1, 3], [\sin, -4], 1), 1, bassoonbuf,
						\bassoon, genwarpbus),
					proc8.(\bass27d, Env([0, 1, 0], [0.1, 3], [\sin, -4], 1), 1, bassbuf,
						\bass, genwarpbus),		
				], 
				nil],
/* 28 */		[
				proc7.(\bass28, Env([0, 1, 0], [0.1, 5], [4, -4], 1), 12, 1, 3,
					[\12, 5, -7, 5, -12, 3], flutebus),
				[\bass27, \bass27a, \bass27b, \bass27c, \bass27d]],
/* 29 */		[nil, \bass28],
/* 30 */		[
				[	/* these release themselves */
					proc2b.(\bass30a, Env([0, 1, 1, 0], [0.1, 6, 7], [\sin, 0, -4]),
						6.dbamp, 0.05, 3, 5, bassbuf, 0.1, \bass), 
					proc2b.(\bass30b, Env([0, 1, 1, 0], [0.1, 6, 7], [\sin, 0, -4]),
						6.dbamp, 0.05, 4, 5, cellobuf, 0.1, \cello)
					],
 				nil],
/* 31 */		[
				[	
					proc2b.(\bass31a, Env([0, 1, 0], [0.1, 15], [\sin, -4], 1),
						6.dbamp, Env([0.4, 0.05], [10]), 3, 5, bassbuf, 0.1, \bass), 
					proc2b.(\bass31b, Env([0, 1, 0], [0.1, 15], [\sin, -4], 1),
						6.dbamp, Env([0.4, 0.05], [10]), 4, 5, cellobuf, 0.1, \cello)
					],
 				nil],
/* 32 */		[nil, [\bass31a, \bass31b]],
/* 33 */		[nil, nil],
/* 34 */		[
				[
					{
						celloev.eventDict[\cello33a].release;
						celloev.eventDict[\cello33b].release;
						},
					proc11.(\bass34, Env([0, 1, 0], [1, 4], [\sin, -2], 1), 18.dbamp, bassbus,
						8, 4, [[flutebuf, \flute, \flute05, \flute08], 
							[flutebuf, \flute, \flute09, \flute11], 
							[cellobuf, \cello, \cello12, \cello14],
							[bassbuf, \bass, \bass14, \bass16],
							[flutebuf, \flute, \flute25, \flute26],
							[bassoonbuf, \bassoon, \bassoon06, \bassoon10]
						], 2)
				],
			 	nil],
/* 35 */		[
				[
					{celloev.eventDict[\cello35b].release}, 
					proc11.(\bass35, Env([0, 1, 0], [1, 4], [\sin, -2], 1), 18.dbamp, bassbus,
						6, 2.9, [[flutebuf, \flute, \flute05, \flute08], 
							[flutebuf, \flute, \flute09, \flute11], 
							[cellobuf, \cello, \cello12, \cello14],
							[bassbuf, \bass, \bass14, \bass16],
							[flutebuf, \flute, \flute25, \flute26],
							[bassoonbuf, \bassoon, \bassoon06, \bassoon10]
						], 2)
					],
				\bass34],
/* 36 */		[
				proc7a.(\bass36, Env([0, 1, 0], [0.1, 1], \sin, 1), 1, 9, 2, [12, 3, 7, 15],
					bassbuf, \bass, bfbus), 
				\bass35],
/* 37 */		[
				proc7a.(\bass37, Env([0, 1, 0], [0.1, 1], \sin, 1), 1, 7, 2, [12, 3, 7, 15],
					bassbuf, \bass, bfbus), 
				\bass36],
/* 38 */		[
				{celloev.eventDict[\cello41].release;},
				\bass37],
/* 39 */		[
				[	
					proc2b.(\bass39a, Env([0, 1, 0], [0.1, 5], [\sin, -4], 1),
						6.dbamp, Env([0.4, 0.8], [10]), 3, 3.5, bassbuf, 0.1, \bass), 
					proc2b.(\bass39b, Env([0, 1, 0], [0.1, 5], [\sin, -4], 1),
						6.dbamp, Env([0.4, 0.8], [10]), 4, 2.9, cellobuf, 0.1, \cello)
					],
 				nil],
/* 40 */		[
				proc7a.(\bass40, Env([0, 1, 0], [0.1, 10], \sin, 1), 1, 8, 2, [12, 3, 7, 15], 
					bassbuf, \bass, bfbus), 
				[\bass39a, \bass39b]],
/* 41 */		[
				[
				 	{
				 		fluteev.eventDict[\flute42a].release;
				 		fluteev.eventDict[\flute42b].release;
				 		celloev.eventDict[\cello42].release				 	}, 
				 ],
				 \bass40],
/* 42 */		[
				[
					proc7c.(\bass42, Env([0, 1, 1, 0], [1, 60, 20], [4, \lin, -2], 1), 1, 
						proc7cbus, bfbus),
					proc7a.(\bass42a, Env([0, 1, 1, 0], [1, 60, 20], [4, \lin, -2], 1), 1,
						Env([3, 7], [15]), Env([3, 4.9], [25]), [-12, 5, -7, 5, -12, 3],
						flutebuf, \flute, proc7cbus),
					proc7a.(\bass42b, Env([0, 1, 1, 0], [1, 60, 20], [4, \lin, -2], 1), 1,
						Env([3, 7], [15]), Env([3, 4.9], [25]), [-12, 5, -7, 5, -12, 3],
						cellobuf, \cello, proc7cbus),
					proc7a.(\bass42c, Env([0, 1, 1, 0], [1, 60, 20], [4, \lin, -2], 1), 1,
						Env([3, 7], [15]), Env([3, 4.9], [25]), [-12, 5, -7, 5, -12, 3],
						bassoonbuf, \bassoon, proc7cbus),
					proc7a.(\bass42d, Env([0, 1, 1, 0], [1, 60, 20], [4, \lin, -2], 1), 1,
						Env([3, 7], [15]), Env([3, 4.9], [25]), [-12, 5, -7, 5, -12, 3],
						bassbuf, \bass, proc7cbus)
				], 
				nil],
/* 43 */		[nil, [\bass42, \bass42a, \bass42b, \bass42c, \bass42d]]
		],
		1, bassinit, basskill, "Bass", s);
	
//	pevents = [fluteev, celloev, bassoonev, bassev];
	
	pevents = Dictionary.with(
		\flute -> fluteev, 
		\bassoon -> bassoonev, 
		\cello -> celloev,
		\bass -> bassev);
	
	/* set-up the GUI and pedal trigs */
	{	
		screenBounds  = GUI.window.screenBounds;
		sbHeight = screenBounds.height;
		sbWidth = screenBounds.width;
		
		flutegui = fluteev.perfGUI(Rect(sbWidth * 0.05, sbHeight * 0.1, sbWidth * 0.3, 
				sbHeight * 0.3),
			Color(0.7, 0.3, 0.3, 0.7)); //.pedalTrig(flutepedal, 200, 2);
		cellogui = celloev.perfGUI(Rect(sbWidth * 0.1, sbHeight * 0.6, sbWidth * 0.3, 
				sbHeight * 0.3),
			Color(0.3, 0.7, 0.3, 0.7)); //.pedalTrig(cellopedal, 200, 2);
		bassoongui = bassoonev.perfGUI(Rect(sbWidth * 0.5, sbHeight * 0.6, sbWidth * 0.3, 
				sbHeight * 0.3),
			Color(0.3, 0.3, 0.7, 0.7)); //.pedalTrig(bassoonpedal, 200, 2);
		bassgui = bassev.perfGUI(Rect(sbWidth * 0.55, sbHeight * 0.1, sbWidth * 0.3, 
				sbHeight * 0.3),
			Color(0.7, 0.3, 0.7, 0.7)); //.pedalTrig(basspedal, 200, 2); 
		}.defer;
	})
}.value;