Shop OBEX P1 Docs P2 Docs Learn Events
PASM Pink Noise Generator — Parallax Forums

PASM Pink Noise Generator

Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
edited 2010-04-07 08:51 in Propeller 1
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.

Comments

  • VIRANDVIRAND Posts: 656
    edited 2010-01-14 02:30
    I think that the noise produced has no randomness in phase space, since the phase is locked to the clock and
    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)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-01-14 03:44
    VIRAND said...
    I think that the noise produced has no randomness in phase space, since the phase is locked to the clock and becomes more so toward the low end of the spectrum.
    Perhaps you could explain for all our benefits how this might compromise the algorithm's usefulness, say, as a means to analyze the performance of audio systems.

    Thanks,
    -Phil
  • VIRANDVIRAND Posts: 656
    edited 2010-01-14 08:40
    It's GREAT for testing audio systems! Only EVIL ones flunk. That's the privacy feature.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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)
  • TonyWaiteTonyWaite Posts: 219
    edited 2010-01-14 13:55
    Phil,
    This code is GREAT
    I'm working through it in order the better to understand it.
    It's fabulous!
    T o n y
  • LeonLeon Posts: 7,620
    edited 2010-01-14 14:45
    It could be tested by saving the output to a file and analysing it on the PC. That would be advisable before actually using it.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
  • TonyWaiteTonyWaite Posts: 219
    edited 2010-01-14 14:46
    Possible pink-noise analysis route:

    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
  • LeonLeon Posts: 7,620
    edited 2010-01-14 14:51
    It would be much easier to do the testing on a PC. I'd use Scilab.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
  • TonyWaiteTonyWaite Posts: 219
    edited 2010-01-17 14:10
    Hi Phil,

    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
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-01-17 18:08
    Tony,

    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
  • TonyWaiteTonyWaite Posts: 219
    edited 2010-01-17 18:55
    @Phil
    Cheers! My analysis was wrong as always ...
  • mellowgurlmellowgurl Posts: 1
    edited 2010-04-07 08:51
    white noise machine produce a gentle, innocuous sound that helps to drown out noise.
Sign In or Register to comment.