From: salsaman <sal...@xs...> - 2004-10-01 12:06:30
|
Dennis Smit wrote: >On Fri, 2004-10-01 at 11:48 +0200, Burkhard Plaum wrote: > > >>>#include <sys/time.h> >>>struct timeval tv; >>> >>>gettimeofday(&tv,NULL); >>>fastsrand(tv.tv_usec); >>> >>> >>> >>Yea, that's the best method :-) >> >>BTW all plugins must be changed to no longer call >>[s]rand(). >> >> > >Yep, I saw xscreensaver has something that gives a warning or an error >on srand, not sure how they do that... > >Cheers, >Dennis > > > Well I am not exactly sure about that now. I have realised that tv_usec could be cyclic on some machines, so it might be better to seed with /dev/urandom if that device exists. The algorithm itself seems to produce enough random noise to be useful, you can check this for yourself with the "noise" real time effect in LiVES. FYI, it was originally in effecTV but used non prime numbers. My contribution was to switch to primes, which eliminated an apparent periodicity in the noise effect. Salsaman. |