[sdiy] Uniformly distributed noise generator?

ASSI Stromeko at nexgo.de
Mon Jun 17 19:28:48 CEST 2013

On Monday 17 June 2013, 14:42:57, rburnett at richieburnett.co.uk wrote:
> Brian, as far as I know that should result in truely white noise, but I
> haven't tried it!  As long as you clock the shift register enough times
> to completely "flush through" each newly injected noise bit, then I
> think each output value spat out will be decorrelated from the previous.

The "rule of the LFSR" is to take exactly one bit per clock out of it or 
things will be correlated (aka "a filtered version of the random 
bitstream").  Depending on where you take those bits from the filtering 
effect may or may not be obvious.

> It's kind of like oversampling the LFSR and then only keeping every
> n'th value, (decimating the output by n.)

An LFSR simply produces a single pseudo-random bit per clock, no matter how 
long its internal state.  If you must describe this in terms of sampling, 
then taking several bits per clock out of the state word is _upsampling_ the 
noise signal followed by a linear filter. Depending on the tap sequence of 
the LFSR and the state bits you siphon off, the length of the impulse 
response varies from painfully obvious to practically infinite, but 
technically it will always be an FIR.

> I like Tom's suggestion.  If you're going to run the LFSR algorithm 8
> times between spitting out each noise byte, then it's defintely worth
> shifting chunks of the LFSR around in whole bytes and doing the eight
> XOR calculations in parallel with a single microcontroller instruction.
> That's a neat implementation optimisation.

You can do it in hardware too and you can find different ways to do it 

> Of course any oversampling does burn instruction cycles, but you can't
> have everything for nothing.

Again, what you're talking about is loop unrolling (in software terms), not 
oversampling.  In mathematical terms, you're looking at a matrix 
exponential, which can give insight into which generators lead to "easier" 
implementations (less deep XOR trees), given the number of state bits and 
bits to take out on each clock.

> For synthesis applcations where I can get away with 1-bit noise I
> personally just take a single bit from a long LFSR noise generator in
> the knowledge that the spectrum is flat.  (It will sound white even if
> the amplitude distribution is not even, or Gaussian, or whatever.)  If I
> need a 16-bit random word for something like a control signal, I can
> usually live with the less than perfect spectrum, or will correct it
> with an IIR post-filter.

Best you can do is compensate the impulse response so that you get the 
original sequence with zeros inbetween (see above).

> I also find the sound of the LCG noise generator somwehat more pleasing
> than LFSR.  Although the mathematicians and cryptanalysts say it has
> terrible randomness properties it somehow sounds cleaner to my ears, and

In other words: you like some correlation in your noise source.

> doesn't have those occasional little pitched chirps that you hear in
> LFSR implementations.

I can easily see where these are coming from if you take out several bits 
per clock from an LFSR or if you clock the LFS (much) lower than the sample 
rate.  Otherwise you really shouldn't have such artefacts.

+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Waldorf MIDI Implementation & additional documentation:

More information about the Synth-diy mailing list