Sub-sample accurate granulation with random periods

damn, this is absolutely huge!!!
I have figured out a way to create linear ramps between 0 and 1 with random periods just with one Duty, so everything is demand rate. maybe this helps to have scheduling triggers perfectly in sync.

(
var rampToRandom = { |rate, randomness|
	var randomPeriod = Ddup(2, 2 ** (Dwhite(-1.0, 1.0) *  randomness)) / rate;
	Duty.ar(
		// update every sample
		dur: SampleDur.ir,
		// reset every randomPeriod
		reset: randomPeriod,
		// "sample and hold" increment of (SampleDur.ir / randomPeriod) for every randomPeriod
		// to increment for each sample by the sample count multiplied by slope modulus 1
		level: Ddup(SampleRate.ir, SampleDur.ir / randomPeriod) * Dseries(0, 1) % 1
	);
	
};

{
	rampToRandom.(\rate.kr(200), \randomness.kr(1));
}.plot(0.021);
)
1 Like