[PD] random oscillation between two values

Matteo Sisti Sette matteosistisette at gmail.com
Sun Aug 22 21:17:38 CEST 2010


In my patches (especially in visual ones) I often need some value to 
randomly "oscillate", or change smoothly, between two extremes, at 
regular intervals (e.g. change every frame).

For this purpose I often use filtered noise: [random] followed by a 
filter of the kind
with 0<a<1

This is fine when I don't need to have a very precise control over the 
range and especially when it doesn't have to be controlled dinamically, 
so I just adjust the "smoothness" and compensate the gain by trial and 
But when I need to easily control the minimum and maximum and have a 
parameter that controls "smoothness" in a natural way, I am not very 
satisfied with this approach.

Another technique I use is to have a random increment (which can be 
positive or negative) added to the current value; then I can force it to 
"bounce" when it reaches either extreme. Same as above: it works but is 
often unsatisfying.

What do you usually use in these situations? I'd prefer a roughly 
uniform distribution of the final result over a gaussian one, or at 
least one that would have a minimum and a maximum without clipping (the 
problem with a gaussian is that you either get a peak in probability of 
the extreme values, or in order to avoid them, you get very low density 
for any value near them)....

I know this is not a well-defined problem, that there are hundreds of 
answers with advantages and disadvantages depending on the application; 
but I guess many of you have often needed something similar and I'd like 
to hear what are your favourite solutions.


More information about the Pd-list mailing list