SimpleClass : NSObject {
	var synth, values;
	
	init {
		if(super.init == nil) { ^nil; };
	
		values = [\density, 0.17, 
				 \rq, 0.003,
				 \freqRange, 1.0,
				 \decayLen, 15.0,
				 \reverbVol, 0.2];
	}
	
	start_ { |sender|
		if(synth != nil) {
			synth.free; synth = nil;
			sender.setTitle_("Start");
		} {
			sender.setTitle_("Booting...");
			sender.setEnabled_(false);
			Server.default.waitForBoot({
				synth = SynthDef(\example, { arg density, rq, freqRange, decayLen, reverbVol;
					var s, z, y;
					// 10 voices of a random sine percussion sound :
					s = Mix.ar(Array.fill(10, { Resonz.ar(Dust.ar(density, 50), 200 + (3000.0.rand * freqRange), rq)}) );
					// reverb predelay time :
					z = DelayN.ar(s, 0.048);
					// 7 length modulated comb delays in parallel :
					y = Mix.ar(Array.fill(20,{ CombL.ar(z, 0.1, LFNoise1.kr(0.1.rand, 0.04, 0.05), decayLen) })); 
					// two parallel chains of 4 allpass delays (8 total) :
					4.do({ y = AllpassN.ar(y, 0.050, [0.050.rand, 0.050.rand], 1) });
					// add original sound to reverb and play it :
					Out.ar(0, s+(reverbVol*y)*3);
				}).play(Server.default, values);
	
				sender.setEnabled_(true);
				sender.setTitle_("Stop");
			});
		};
	}

	setValue_forKey_ { |value, key|
		var num = values.indexOf(key.asSymbol);
		
		if(num != nil) {
			values[num+1] = value;
		};	
		
		format("setting %: %", key, value).postln;
		if(synth != nil) {
			synth.set(key, value);
		};
	}
	
	valueForKey_ { |key|
		var num = values.indexOf(key.asSymbol);
		
		if(num != nil) {
			^values[num+1];
		} {
			^nil;
		};
	}

	windowWillClose_ { |notification|
		if(synth != nil) {
			synth.free;
		};
	}
}