[linux-audio-dev] ANN: libgdither 0.6

fons adriaensen fons.adriaensen at skynet.be
Mon Jul 25 18:56:49 UTC 2005


On Mon, Jul 25, 2005 at 07:37:14PM +0200, Wolfgang Woehl wrote:

> Me being noisy all the time I still don't know the maths of making 
> noise. Would you care to explain the rationale in this snippet from 
> noise.h?
> 
> inline static float gdither_noise()
> {
>     static uint32_t rnd = 23232323;
>     rnd = (rnd * 196314165) + 907633515;
>     return rnd * 2.3283064365387e-10f;
> }

It's a 'linear congruential sequence generator', one of the simplest
and fastest ways to generate uniform random variables. For a (very
complete) analysis of this algorithm, see D.E. Knuth, "The Art of
Computer Programming", Vol.2. The final multiply reduces the output
to the interval [0,1].

The integer computation done is of the form
 
  x = (x * a + b) mod m

and here m = 2^32. For this m, to get the best results, you need

  a mod 8 = 3 or 5  (196314165 mod 8 = 5)
  gcd (b, m) = 1    (so 1 would be as good as 907633515)


-- 
FA



More information about the Linux-audio-dev mailing list