@porres said:
to never miss a period, but I also think this is a job for a C code.
To atone for my earlier SC jibe, here's a delay-based approach. (Also, indeed you're right -- I hadn't read the thread carefully enough. Dust / Dust2 don't implement exactly "one pulse per regular time interval, randomly placed within each interval.")
velvet-noise-2.pd
Uses else's del~ because delread~ requires a message-based delay time, which can't update fast enough, and delread4~ interpolates, which smears the impulses. With del~, I could at least round the delay time to an integer number of samples, and AFAICS it then doesn't interpolate.
It looks to me in the graphs like there is exactly one nonzero sample per phasor~ cycle.
hjh
PS FWIW -- one nice convenience in SC is that non-interpolating DelayN doesn't require the delay time to be rounded
(
a = { |density = 2500|
// var pulse = Impulse.ar(density);
// for similarity to Pd graphs, I'll phasor it
// but the Impulse is sufficient for the subsequent logic
var phasor = LFSaw.ar(density);
var pulse = HPZ1.ar(phasor) < 0;
var delayTime = TRand.ar(0, density.reciprocal - SampleDur.ir, pulse);
var rand = TRand.ar(-1, 1, pulse).sign;
[DelayN.ar(rand * pulse, 0.2, delayTime), phasor]
}.plot;
)