[sdiy] different distributions from LFSR was: (oops) EN #76 question

Scott Nordlund gsn10 at hotmail.com
Thu Feb 7 08:29:21 CET 2013


> From: Stromeko at nexgo.de
> To: synth-diy at dropmix.xs4all.nl
> Date: Thu, 7 Feb 2013 00:19:06 +0100
> Subject: Re: [sdiy] different distributions from LFSR was: (oops) EN #76 question
>

> Taking out multiple taps from the same LFSR will never yield a truly pseudo-
> random signal unless you clock the the LFSR so that the complete state gets
> cycled through the tap sequence between each "take-out" or sampling. The
> numbers will be uniformly distributed, but there is high correlation at
> time-scales related to the tap sequence (just like the numbers out of a
> free-running binary counter will be uniformly distributed, just very
> predictably correlated to the counter period). It is easy to see that
> successive binary-weighted taps (or taking the complete state as a binary
> word) result in (sums of) exponentials signal and that trait will also be
> present if the taps get distributed differently. EN212 actually describes
> this on page 15. That already is a form of filtering (think delta pulses
> convoluted with exponentials), so by changing the weigths for each tap you
> get to play with the filter function a bit more.

I know that any filtering adds correlation, but I thought that would be the fun part: to have a random source that's correlated but still fits a particular distribution (and isn't a bounded random walk or similar). I don't usually like filtering random signals, as the distribution and other properties aren't well controlled. But it's nice if filtering turns it into something useful. In particular I think the allpass is interesting because all the distributions that can be obtained from different filter coefficients have the same total power.

> There were some students at our university that played with non-maximum-
> length LFSR to get noise with non-white spectrum (for use in acoustic room
> simulations on scaled models). Aside from the fact that the lower frequency
> always seems to come in easily discernible bunches this gave them a
> relatively easy way to quickly switch to different noise spectra with
> predictable properties (to then lift the room impulse response from the
> measurements made on the model). You need to take care that the LFSR
> doesn't get stuck in degenerate cycles or jumps to the wrong one, though.

That gave me a neat idea. I previously made a Triadex Muse clone in software (31 stage shift register with arbitrary feedback and output taps). I like it, as the non-maximum-length sequences can be interesting, but for random note generator purposes, I don't think binary weighting of 4 taps is very useful. So instead I put a single tap through this filter thing. I think the results are more interesting than what I was getting from a "good" binary random source.

I recorded a quick demo with Pure Data, using this and some other stuff that I've been working on recently (synthesis and reverb algorithms): http://www.mediafire.com/?g3clr1micmkd0i9

I'm using the Triadex Muse thing through an allpass filter with a feedback coefficient of 0.5 (-0.5 sounds noticeably different). It's playing a major scale over 4 octaves, with the middle two octaves occurring twice as often as the lowest and highest. I verified that the histogram looks the same as the one I'm getting in Octave. After a while you start to notice certain repeating motifs (like an exponential decay when the input is a string of zeros or ones). I thought that this sort of established a sense of a "tonal center", so to add some more variety I occasionally rotate the scale (independently in the top two and bottom two octaves). And since the exponential decay motif goes down in the lower octave and up in the higher octave, I also sometimes invert the scale. I think this is about all the melodic variety that this technique has to offer, at least in this form. But I think it sounds pleasant enough, and  audibly unique compared to a typical uniform random note generator (or random walk).

Here's the Octave code. I haven't tested it in Matlab, but I think it won't run without some changes.


%2-5-2013

x1 = [1,zeros(1,127)];                                                          %impulse
x2 = 2*(rand(1,1000000)>0.5)-1;                                         %pseudorandom binary sequence, +/- 1
ap = 1;                                                                                         %select allpass (1) or low/highpass (0) response
coef = 0.5;                                                                             %(use 0.5 for uniform)> 0 is lowpass,< 0 is highpass

if ap
        b = [-coef,1]; a = [1,-coef];                                     %apf, y2 is a "stepped" distribution if coef = +/- 0.5
else
        b = [1-abs(coef)]; a = [1,-coef];                                %lpf/hpf, y2 is uniform if coef = +/- 0.5
end

y1 = filter(b,a,x1);
y2 = filter(b,a,x2);
figure(1)
plot(y1); title('impulse response')
figure(2)
hist(y2,100); title('histogram')
figure(3)
semilogx(20*log10(abs(fft(y1)(1:floor(length(y1)/2))))); title('impulse response spectrum')
%figure(4)
%semilogx(20*log10(abs(fft(y2)(1:floor(length(y2)/2))))); title('pseudorandom spectrum')
 		 	   		  


More information about the Synth-diy mailing list