[PD-dev] Random method in noise~ question....
chun lee
leechun at leechun.freeserve.co.uk
Fri Oct 22 11:12:50 CEST 2004
Hi there:
Thanks for your comments:)
>> 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]);
> getting arguments ...
>
>> int val = *vp;
> setting seed
>
>> while (n--)
>> {
> looping over the dsp block
>
>> *out++ = ((float)((val & 0x7fffffff) - 0x40000000)) *
>> (float)(1.0 / 0x40000000);
> scaling the random number between -1 and 1
>
Ummmm, I don't quite understand this scaling code, especially with the long
numbers. Is this like the fast way of doing scaling? Like doing bit shifting
is fast multiplying?
>> val = val * 435898247 + 382842987;
> generating new random number
>
This is the bit that I really like to learn, you can get random number by
adding two large numbers times the seed? Also how does the seeding method
works?
static int init = 307;
x->x_val = (init *= 1319);
>> }
>> *vp = val;
> dont forget it
>
>> return (w+4);
>> }
> done ...
>
> if you are interested in different noise generators most of the noise
> generators from supercollider (quite a log actually) are part of sc4pd
> ... an sc header file contains the inline functions for the rngs ...
Cool, I will look into that. I don't know of sc4pd, what is it? I did wonder
why supercollider is in Pd's CVS. Does sc4pd allows you to do/script/run
supercollider in Pd?
Many thanks again
CHUN
More information about the Pd-dev
mailing list