PASM Pink Noise Generator
Phil Pilgrim (PhiPi)
Posts: 23,514
In another thread there was a question about generating pink noise with the Propeller. I did a little research on how this could be done and came up with the attached program. It uses the Voss-McCartney algorithm. In this algorithm, n random numbers are added together to yield the instanteous amplitude at each sample time. Only one of the random numbers is changed at each sample, and the changes (LFSR iterations, in this case) are scheduled such that each successive random number gets changed half as often as the one before it.* This means, in essence, that each octave has its own white noise generator. By adding the generators for all the octaves, we get pink, or 1/f noise.
I ran the program on a Propeller Demo Board, using the A10 output so I could listen to the result. By starting the constant NRAND from 1 and working upwards, you can hear the noise becoming successively "richer". I have no way to measure the quality of this program's output. Perhaps someone with fancy audio test equipment can put it through its paces and verify whether it really is accurately rendered pink noise or not.
-Phil
* The order in which the random numbers are changed is related strongly to Gray code. In a Gray code sequence, only one bit changes at a time. The random number corresponding to the bit that changes at each Gray code step is the one that gets changed in this algorithm.
I ran the program on a Propeller Demo Board, using the A10 output so I could listen to the result. By starting the constant NRAND from 1 and working upwards, you can hear the noise becoming successively "richer". I have no way to measure the quality of this program's output. Perhaps someone with fancy audio test equipment can put it through its paces and verify whether it really is accurately rendered pink noise or not.
-Phil
* The order in which the random numbers are changed is related strongly to Gray code. In a Gray code sequence, only one bit changes at a time. The random number corresponding to the bit that changes at each Gray code step is the one that gets changed in this algorithm.
spin
13K
Comments
becomes more so toward the low end of the spectrum. It can be used as a countermeasure against bugs, for
a specifically different kind of eavesdropped sound than what white noise LFSRs mask.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
VIRAND, If you spent as much time SPINNING as you do Trolling the Forums,
you'd have tons of awesome code to post! (Note to self)
Thanks,
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
VIRAND, If you spent as much time SPINNING as you do Trolling the Forums,
you'd have tons of awesome code to post! (Note to self)
This code is GREAT
I'm working through it in order the better to understand it.
It's fabulous!
T o n y
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
I'm just getting my head around the Fast Hartley Transform thread; specifically extraction of the power spectrum then
the phase magnitude etc as a measure of goodness of this new PASM coding.
There's a VGA demo too listed within the thread, that I'll run tonight.
T o n y
http://forums.parallax.com/forums/default.aspx?f=25&m=397279
Post Edited (TonyWaite) : 1/14/2010 3:00:47 PM GMT
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
I'm looking to limit the output frequency to the range 50-5000Hz.
Here my maths follows, which is normally wrong but here goes:
So 50-5000Hz gives me period 1/f of 0.02 to 0.0002 seconds respectively.
And looking at the PASM, I'm guessing that in the 'strand' section, a limit could be inserted
where freqa is updated with the new value prior to output. In other words to check whether the
effective output be outside these frequency bounds ( ie 1/p <.0002>0.02); if so, then throwaway.
Is this correct?
Regards, T o n y
It takes more than one sample or a pair of them to determine what the frequency is. So doing an accept/reject at each step will not shape the spectrum the way you want without considering the output from many steps prior. But then you might as well just generate white noise and use a FIR or IIR post-filter to shape the spectrum.
I think it would be easier to lower the overall update rate to limit the high-frequency response. I was using 88 kHz. If you change it to 20 kHz, you will get closer to your 5 kHz top end.
-Phil
Cheers! My analysis was wrong as always ...