[PD-dev] Random method in noise~ question....
chun lee
leechun at leechun.freeserve.co.uk
Fri Oct 22 01:28:11 CEST 2004
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
More information about the Pd-dev
mailing list