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

chun lee leechun at leechun.freeserve.co.uk
Mon Oct 25 13:03:45 CEST 2004


Hi miller:

Thanks for your reply, I found the links below in implementing the minimal
standard/Lehmer RNG.


http://www.sbc.su.se/~per/crng/seminar/rng5.html
http://www.cs.virginia.edu/~jcc5t/classes/undergrad/simulation/random/rng.c

In addition, what is the period of the homebrew method? Also, are the large
numbers 435898247, 382842987 specifically chosen or they works as long as
they a sufficiently large?

Cheers

CHUN

On 25/10/04 5:00 am, "Miller Puckette" <mpuckett at man104-1.ucsd.edu> wrote:

> 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