paying tribute to the icelandic trevor wishart - an attempt at emulating the work of the great composer bjarni gunnarsson
(
{
var snd, chaos, chaosClass;
var tendMask1, tendMask2;
var satAmount, crushed, clipped, saturated;
var downsampleRate, bitcrushed, wetMix;
var samplerate, hold;
// Gendy tone
snd = Gendy1.ar(1, 1, 1, 1, 440, 660, 0.5, 0.5, 12, 1, 1, 0);
// Add fast noise
snd = snd + LFDNoise0.ar([rrand(1.0, 30.0), rrand(1.0, 30.0)]);
// Add chaotic generator
chaosClass = [LorenzL, LatoocarfianL, LinCongL, StandardL].choose;
chaos = chaosClass.ar([rrand(1.0, 30.0), rrand(1.0, 30.0)]);
snd = snd + chaos;
// Add random dust clicks
snd = snd + Dust2.ar(rrand(1.0, 10.0)!2);
// --- Stochastic tendency masks ---
tendMask1 = LFSaw.kr(rrand(0.01, 0.1)).range(0, 1);
tendMask2 = LFNoise1.kr(rrand(0.05, 0.2)).range(0, 1);
// --- Extreme saturation section ---
satAmount = tendMask1 * 20 + 5; // Saturation drive between 5 and 25
crushed = snd * satAmount;
// Hard clipping + tanh distortion
clipped = crushed.clip2(1);
saturated = clipped.distort;
// Bitcrush effect via sample-and-hold
downsampleRate = tendMask2.linexp(0, 1, 0.01, 0.2);
samplerate = (downsampleRate * SampleRate.ir).round(1).max(1);
hold = Latch.ar(saturated, Impulse.ar(samplerate));
bitcrushed = hold;
// Mix dry/wet with stochastic mix amount from tendency mask
wetMix = tendMask2;
snd = XFade2.ar(snd, bitcrushed, wetMix * 2 - 1); // crossfade from dry to wet
// Basic processing
snd = LeakDC.ar(snd);
snd = Limiter.ar(snd*6, 0.95);
//snd = snd * 0.1;
Out.ar(0, snd);
}.play;
)