(
s.waitForBoot({

	s.newBusAllocators;
	~revbus = Bus.audio(s, 2);

	SynthDef(\rhubarb, {
		var bn, pn, osc, sig, env, freq = \freq.ir(440);
		bn = Crackle.ar(1.99!4); // EMF: I find crackle is more interesting with a choas parameter closer to 2
		bn = LPF.ar(bn, 1000); // EMF: 10 is such a low cutoff frequency that you're essentially muting the crackle UGen. Raised to something higher
		bn = GlitchBPF.ar(bn, freq * {Rand(-0.2, 0.2).midiratio}.dup(4), \rq.ir(0.01), 24);
		osc = LFSaw.ar(freq * {Rand(-0.2, 0.2).midiratio}.dup(4), {Rand(0.48, 0.52)}.dup(4));
		osc = LPF.ar(osc, (freq * 2).clip(20, 20000));
		osc = osc * LFDNoise3.kr(0.1!4).exprange(1.1, 1.5);
		osc = Fold.ar(osc, -20, 20); // EMF: wavefolding only happens if the input signal amplitude exceeds the bounds provided. osc has a pretty normal range and won't ever exceed ±20. You can see in the previous line (LFDNoise3) I'm only amplifying it by a maximum factor of 1.5. It's actually small boundary values with Fold that cause audible results (change to the folding min/max to -0.1, +0.1 and you'll notice the sound changes significantly)
		osc = LPF.ar(osc, 400).tanh(20) * 0.12;
		env = Env.asr(\atk.kr(0.35), \sus.kr(1), \rel.kr(2), \crv.ir(-2)).ar(2, \gate.kr(1));

		// EMF: Passed pink noise through lowpass filter before mixing to better mirror spectral profile of original track
		sig = bn + osc + LPF.ar(PinkNoise.ar(0.015!4 * LFDNoise3.kr(1).exprange(0.35, 1)), 3000);
		sig = sig * LFDNoise3.kr(0.1!4).exprange(1.1, 1.2);
		sig = Splay.ar(sig, spread: 10); // EMF: spread caps out at 1, larger values don't do anything extra
		sig = sig.tanh * \amp.ir(0.25);

		/*sig = sig + BPF.ar(sig, 400, 0.3, 1, 0);
		sig = sig + GlitchBPF.ar(sig, 400, 1, 1, 0) * 0.1;*/

		// EMF: reduced Comb mul parameter to less than 1, the delay felt too prominent
		sig = sig + CombL.ar(sig, maxdelaytime:0.2, delaytime:0.2, decaytime: 1.0, mul: 0.3) * 0.4;

		sig = sig * env * 4; // EMF upscaled output gain to a healthier level
		Out.ar(\out.ir(0), sig);
	}).add;

	SynthDef(\reverb, {
		var sig, verb;
		sig = In.ar(\in.ir(~revbus), 2);
		verb = GVerb.ar(sig.sum, 299, 1);
		// verb = JPverb.ar(verb, 299, 1);
		verb = JPverb.ar(verb, t60: 2.0, damp: 0.0, size: 3.0, earlyDiff: 0.1, modDepth: 0, modFreq: 1.0, low: 1.0, mid: 1.0, high: 1.0, lowcut: 500.0, highcut: 2000.0);
		verb = LPF.ar(verb, \lpf.ir(12500), \amp.ir(0.2));
		sig = sig.blend(verb, \mix.kr(0.8));
		Out.ar(\out.ir(0), sig);
	}).add;

	s.sync;

	~rev = Synth(\reverb, [in: ~revbus, out: 0], s, \addAfter);

	t = TempoClock(86/60);

	p = Pbind(
		\instrument, \rhubarb,
		\dur, Pseq([ 1.5, 4.5, 1.5, 1.5, 5 ], inf),
		\sustain, Pkey(\dur),
		\midinote, Pseq([
			[ 57, 62, 66 ],
			[ 54, 57, 61 ],
			[ 57, 61, 64 ],
			[ 52, 56, 59 ],
			Prand([[ 33, 50, 54, 57], [ 50, 54, 57 ]], 1),
		], inf) - 0.1,
		\amp, 1,
		\atk, Pwhite(0.2, 0.5),
		\rel, Pexprand(1.2, 2.5),
		\out, ~revbus
	).play(t)
});
)