DSPRelated.com
Forums

Generate Pink Noise Efficiently

Started by Robert Scott March 19, 2013
On Sun, 24 Mar 2013 00:43:43 GMT, no-one@notreal.invalid (Robert
Scott) wrote:

>OK, here is the method that I ended up using. I generate a square >wave of random period, or rather a random half-period. I start with a >randon number uniformly distribute between 400 and 655. This number >is multiplied by a value that ranges from 635 nsec to 1134 nsec, >depending on the parameter value I am trying to communicate. The >resulting time is the length of the next square wave Hi or Low time. >After that time I toggle the output and generate another random number >for the next half-period. The result sounds about right. > >The spectrum of the frequency-jittered square wave is not just a >single wide peak but has significant harmonics that are also >spread-spectrum. But the overall sensation of rising or falling pitch >is conveyed, much like the Shepard Tones mentioned earlier. > >Robert Scott >Hopkins, MN
That's nice, since it's easy to generate and accomplishes the task. Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
Robert Scott <no-one@notreal.invalid> wrote:
> OK, here is the method that I ended up using. I generate a square > wave of random period, or rather a random half-period. I start with a > randon number uniformly distribute between 400 and 655. This number > is multiplied by a value that ranges from 635 nsec to 1134 nsec, > depending on the parameter value I am trying to communicate. The > resulting time is the length of the next square wave Hi or Low time. > After that time I toggle the output and generate another random number > for the next half-period. The result sounds about right.
So, the inverse of a phase accumulator. The usual way would be to generate a number, which is the phase increment, so proportional to frequency, then add it to a (possibly large word size) accumulator, modulo some value (usually a power of two). For a square wave output, you just take the high bit. For a sine, you use the high bits for a sine lookup table.
> The spectrum of the frequency-jittered square wave is not just a > single wide peak but has significant harmonics that are also > spread-spectrum. But the overall sensation of rising or falling pitch > is conveyed, much like the Shepard Tones mentioned earlier.
-- glen