I would like to create a Pd equivalent of SuperCollider's LFDNoise1 LFO (random line segments).
It's basically like this. In Pd, I can see how to do almost all of it, except for sample/holding the previous random value.
(
a = {
// pd: phasor~
var phasor = LFSaw.ar(1) * 0.5 + 0.5, // 0-1
// pd: [rzero~ 1] --> [<~ 0]
trig = HPZ1.ar(phasor) < 0, // 1 when phasor drops
// pd: [samphold~]
nextEndpoint = Latch.ar(WhiteNoise.ar, trig),
// pd: I don't know how to do this
prevEndpoint = Latch.ar(Delay1.ar(nextEndpoint), trig),
// pd: easy math
line = (nextEndpoint - prevEndpoint) * phasor + prevEndpoint;
// simple test signal: map bipolar LFO exponentially to freq
SinOsc.ar(400 * (2 ** line), 0, 0.1).dup
}.play;
)
a.free;
I made one failed attempt using [phasor~] --> [rzero~ 1] --> [*~ -1] --> [threshold~] --> [random], but if the phasor jumps to zero in the middle of a control block, then the random calculation is out of sync and the output glitches slightly. So I need to keep all of it in the signal domain (no control objects).
Thanks,
hjh