Original Dirt compressor for SuperDirt

on Discord, @yaxu mentioned that he misses the master compressor from the original Dirt. this code is quite simple, so i decided to try implementing it for SuperDirt, with good results :slight_smile: maybe others will enjoy it as well!

(actually this doesnt even depend on anything in SuperDirt, it will work with SuperCollider in general)

// emulation of master compressor from original Dirt
// requires Fb1 from miSCellaeous for single-sample feedback
// https://github.com/dkmayer/miSCellaneous_lib
(
Ndef(\dirtComp, { |amount=1, speed=50|
	var in, max, env;
	in = In.ar(0, ~dirt.numChannels);

	max = Select.ar(ArrayMax.ar(in.abs)[1], in);
	env = Fb1({ |in, out|
		var env, prod;
		env = out[1];
		env = env + (speed / SampleRate.ir);
		prod = (in[0] * env).abs;
		Select.kr(prod > 1, [env, env/prod]);
	}, max, leakDC: false);

	ReplaceOut.ar(0, in * amount.linlin(0, 1, 1, env * 0.2));
}).play(
	group: RootNode(Server.default),
	addAction: \addToTail
);
)

// can also tune the parameters
Ndef(\dirtComp).set(\amount, 1);
Ndef(\dirtComp).set(\speed, 200);

edit: moved the multiplication by 0.2 into its right place

4 Likes

Thanks so much this sounds great!

I'd really missed it, I think bonkers heavy compression like this makes a lot of sense for livecoding, when you haven't got time to tweak volume levels perfectly, and just want everything to interact in interesting ways and make nice patterns..

1 Like

Perhaps it would be good to add it to SuperDirt: Original dirty compressor ยท Issue #304 ยท musikinformatik/SuperDirt ยท GitHub