Re: [linux-audio-dev] ANN: libgdither 0.6

From: fons adriaensen <fons.adriaensen@email-addr-hidden>
Date: Mon Jul 25 2005 - 21:56:49 EEST

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
Received on Tue Jul 26 00:15:12 2005

This archive was generated by hypermail 2.1.8 : Tue Jul 26 2005 - 00:15:12 EEST