[PD-dev] Random method in noise~ question....

Miller Puckette mpuckett at man104-1.ucsd.edu
Mon Oct 25 06:00:58 CEST 2004


Hi Chun,

It's a simple, homebrew pseudo-random number generator.  I'm not
sure where you can find the theory of pseudorandom number generators,
but basically the val = val * 435898247 + 382842987 step mixes up
the set of odd 32-bit integers in a very complicated way.

cheers
Miller

On Fri, Oct 22, 2004 at 12:28:11AM +0100, chun lee wrote:
> Hi there:
> 
> Out of curiosity, I thought I will take a look at how [noise~] is
> implemented. While knowing just enough C to write little externals, I am a
> bit puzzled at the method in which the random number is obtained in here as
> I only know of rand() method in ANSI C. I also looked at the code for
> [random] and they look similar. Homebrew?
> 
> I wonder if anyone could provide some comments on the code or explain a
> little so that I can know how it works.
> 
> static t_int *noise_perform(t_int *w)
> {
>     t_float *out = (t_float *)(w[1]);
>     int *vp = (int *)(w[2]);
>     int n = (int)(w[3]);
>     int val = *vp;
>     while (n--)
>     {
>         *out++ = ((float)((val & 0x7fffffff) - 0x40000000)) *
>             (float)(1.0 / 0x40000000);
>         val = val * 435898247 + 382842987;
>     }
>     *vp = val;
>     return (w+4);
> }
> 
> 
> Many thanks
> 
> Yours
> 
> CHUN
> 
> 
> _______________________________________________
> PD-dev mailing list
> PD-dev at iem.at
> http://iem.at/cgi-bin/mailman/listinfo/pd-dev




More information about the Pd-dev mailing list