[sdiy] Non maximal-length LFSR

rsdio at audiobanshee.com rsdio at audiobanshee.com
Fri Mar 4 11:24:31 CET 2016

On Mar 3, 2016, at 1:33 PM, Tom Wiltshire <tom at electricdruid.net> wrote:
> On 3 Mar 2016, at 21:19, "Richie Burnett" <rburnett at richieburnett.co.uk> wrote:
>>> You are still using bits from the same sequence (each LFSR, a bitslice of
>>> your 48 registers, has the same structure), so you need to carefully
>>> initialize the LFSR states to have a large enough distance.  You reduce the
>>> correlation length by a factor of 16, which is inconsequential if you keep
>>> the sequences the maximum of 2^44 cycles apart, but could have unintended
>>> results if they are quite close together.
>> Hmmm, this is very true.  At present I've just been seeding the LFSRs using 48 iterations of a 16-bit Linear Congruential Generator, without much thought being put into the initial states.  I just checked the spectrum of the white noise output from the algorithm and thought that any short-term correlation between the bits in each word would result in FIR filtering of the noise and therefore result in magnitude ripple in the spectrum.
> Wouldn't it be best to have the "sequence read points" spaced out as much as possible? E.g. Start each separate LFSR with a value roughly 1/16th further through the whole sequence. Obviously finding those values is going to involve either "hard sums" or exhaustive testing, but it's offline, so that's not impossible.

I just thought of another requirement: Whatever your total seed is for the 16 parallel registers, you have to make sure that no bit position ends up initialized to all zeroes. Since these are parallel 1-bit LFSRs, any bit position that is all 0 will produce nothing but 0.

I don't know whether there's a random seed that can fulfill this special requirement, but you can always test the seed for each of the 16 bit positions and re-run the seed if it fails. That could cause a random start-up delay in your code, but you wouldn't want to end up with 15 or fewer random bits and 1 or more 0 bits in every sample!


More information about the Synth-diy mailing list