Ndef(\aix).fadeTime = 10
(
Ndef(\aix, {
	var snd, revt;
	snd = Pulse.ar(freq: LFNoise0.ar([1/2,1/3]).exprange(50,5000));
	snd = snd + RLPF.ar(in: WhiteNoise.ar,
		                freq: LFNoise0.ar(1/3).exprange(1000,10000),
		                rq: LFNoise0.ar(1).range(0.01,1));
	snd = snd * LFPulse.ar(
		freq: LFNoise0.ar(1).exprange(0.1,8),
		width: LFNoise0.ar(1).range(0.1,0.001),
		// this creates very loud spikes - max 1000 above 1:
		mul: LFNoise1.ar(3).exprange(0.01,1000));
	snd = HPF.ar(snd, 10);

	// reverb time - various optons:
	revt = LFNoise0.ar(1/2).exprange(0.0001, 0.1);
	//revt = XLine.ar(1, 0.0001,30);
	//revt = LFTri.ar(1/10, 1).range(0.01, 0.0001);	
	//revt = 0.000001;

	snd = Greyhole.ar(snd, revt, 0.5, revt);
	snd = Limiter.ar(snd, 0.9);
	snd = snd * 1;

}).play)











// THANKS TO/FORKED FROM:
// https://sccode.org/1-5ei
/////////////////////////////////////////////////////////////////////////////////////////////
// what can it sound like? see: https://www.youtube.com/watch?v=dRmY3tEwZyE 
// the youtube version has been sent through an additional reverb pedal, but
// you don't need the pedal to get something that sounds interesting

(
s.options.memSize_(16384*10);
s.reboot;
s.waitForBoot({
	
	Ndef(\bits, {
		var t = PulseCount.ar(Impulse.ar(8e3));
		var u = PulseCount.ar(Impulse.ar(7009));
		var sig = HPF.ar(
			(
				((t * 15) & (t >> 5)) |
				((t * 5) & (t >> [3, 4])) |
				((t * 2) & (t >> 9)) |
				((t * 8) & (t >> 11)) |
				(((t*t) & t) | (t >> 3))
				- 3 % 256
			) / 127-1 * 3
			, 20
		) * 0.1;
		var sig2 = LPF.ar(HPF.ar(gcd(t*u, u+t), WhiteNoise.ar()*2000 + 1000), 20);
		sig2 = sig2*sig;
		sig = 0.3*Splay.ar(Limiter.ar(Greyhole.ar(sig + sig2, sig, 0.5, sig), 0.5).flatten);
	}).play;
});
)
/////////////////////////////////////////////////////////////////////////////////////////////


// REWORK/ANALYSIS:

(
Ndef(\bits,
{
	var t, u, sig, sig2, sum;

	t = PulseCount.ar(Impulse.ar(8e3));
	u = PulseCount.ar(Impulse.ar(7009));

	sig = ( // bytebeat
		((t * 15) & (t >> 5)) |
		((t * 5) & (t >> [3, 4])) |
		((t * 2) & (t >> 9)) |
		((t * 8) & (t >> 11)) |
		(((t*t) & t) | (t >> 3))
		- 3 % 256
		) / 127-1 * 3 ;

	sig = HPF.ar(sig, 20) * 0.1 ;

	sig2 = gcd(t*u, u+t);
	sig2 = HPF.ar(sig2, WhiteNoise.ar() * 2000 + 1000);
	sig2 = LPF.ar(sig2, 20);
	sig2 = sig2 * sig;
	
    sum = Greyhole.ar(in: sig2, delayTime: sig, damp: 0.5, size: sig);
	sum = Limiter.ar(sum, 1);
	sum = sum.softclip;
	sum = sum * 0.5;
	//sig2 * 0.0001;
	sig;

}
) // Ndef
//.play;
//.plot(2,minval:-10, maxval:10); 
.plot(7); 
)

/////////////////////////////////////////////////////////////////////////////////////


