[sdiy] Non maximal-length LFSR

Richie Burnett rburnett at richieburnett.co.uk
Thu Mar 3 16:59:53 CET 2016


> throwing away a byte every now and then sounds reasonable. I would be
> surprised if this causes any audible artefacts.

I think that's what I'll probably do.  I'd rather generate 49 samples and 
throw one away each time, than add two more XOR instructions into my loop 
and increase the CPU load of that function by 100%.

> As far as I know the dsPIC has a CRC engine. CRC is in a nutshell just a
> LFSR so it can likely be abused as a cheap random generator. Have you
> tried that?

It does.  I'm actually using that for CRC checking some downloaded data 
packets in another project.  It's only 16-bit though, so the sequence would 
repeat after 65535 bits.  That's only just under 4096 sample words, or every 
85 ms at 48kHz.  So, unfortunately it would be very noticeable.

> Also you can always mix two not-so-good random streams together to get a
> longer and often better random data stream. Say you have a stream with a
> sequence length N and another one with a sequence length M the xor of
> the two streams yields a random stream of length GCD(m,n).

I can try this, although it is not really "quality" in a mathematical purist 
or Cryptographic sense that I am aiming for as much as "super efficient 
noise source".  The ability to produce 16-bit noise samples with poor 
correlation between the bits in just two instructions per sample is what is 
appealing to me about this technique.

I didn't invent this idea, BTW.  I came across the R250 Random Number 
Generator that uses an array of 250 words in a circular buffer and takes its 
feedback from taps 147 and 250 to produce a sequence of 16-bit random 
numbers that is (2^250)-1 in length!!!!  Obviously this is far longer than 
necessary for audio, but the efficiency of the algorithm is very tempting 
when run on DSP hardware.  Hence me trying to modify it to fit a buffer 
length of 48 words.  (You might say that 48 words is a lot of RAM resources 
to use up generating some random numbers, but I would use this space for the 
1ms output buffer of the noise source anyway.)

-Richie, 




More information about the Synth-diy mailing list