[sdiy] converting white noise to pink noise
Eric Brombaugh
ebrombaugh at earthlink.net
Fri Mar 7 02:37:54 CET 2008
Andre Majorel wrote:
> On 2008-03-04 15:17 -0800, Dave Manley wrote:
>> Andre Majorel wrote:
>>> But note that long period does not imply good sound. For example,
>>> http://www.maxim-ic.com/appnotes.cfm?appnote_number=1743&CMP=WP-9
>>> is a 32-bit LFSR with a 2**32 period that does not sound very
>>> white.
>> Interesting, do you have a sound file you can share?
>
> http://www.teaser.fr/~amajorel/noise/
>
> I'll make another clip using just one bit per iteration as
> suggested by Achim.
Hi Andre,
Thanks for posting your code. Looking through it I can see two problems:
1) You're outputting all 32 bits at every iteration, even though the
algorithm only generates one new bit. Since your generator shifts down
this results in sequences of decreasing logarithmic ramps that give it
an interesting resonant sound.
2) The LFSR polynomial is implemented incorrectly. To write the
implemented algorithm out in pseudocode would look like this:
If bit 0 is set
flip each bit in the shift register with a 1 in the tapmask
shift register down 1 bit
set bit 31
else
shift register down 1 bit
The actual LFSR algorithm is more like this
sample each bit in the shift register with a 1 in the tapmask
xor all the sampled bits
shift the register down 1 bit
put the result of the XOR operation into bit 31
Interestingly, your algorithm actually does generate a PRN sequence, but
it isn't maximal-length. I analyzed its repeat rate and found that it is
107359437 cycles long - about 40x shorter than a maximal-length 32-bit LFSR.
By changing the code for updating the register from
if (r & 1)
r = (1 << 31) | ((r ^ tapsmask) >> 1);
else
r >>= 1;
to
r = r<<1 | (((r>>1)^(r>>5)^(r>>6)^(r>>31))&1);
I got a repeat interval of 4294967295 cycles as expected. Unfortunately,
this code doesn't allow arbitrary taps to be defined at run time though,
so it's not nearly as flexible as your approach. You probably ought to
patent it. :)
Eric
More information about the Synth-diy
mailing list