Pink noise generator

there are several different methods.

you can approximate a -3db/octave “pinking filter” using an FIR, as shown in this snippet posted by paul kellet on musicdsp.org

Filter to make pink noise from white  (updated March 2000)
------------------------------------

This is an approximation to a -10dB/decade filter using a weighted sum
of first order filters. It is accurate to within +/-0.05dB above 9.2Hz 
(44100Hz sampling rate). Unity gain is at Nyquist, but can be adjusted
by scaling the numbers at the end of each line.

If 'white' consists of uniform random numbers, such as those generated
by the rand() function, 'pink' will have an almost gaussian level 
distribution.


  b0 = 0.99886 * b0 + white * 0.0555179;
  b1 = 0.99332 * b1 + white * 0.0750759;
  b2 = 0.96900 * b2 + white * 0.1538520;
  b3 = 0.86650 * b3 + white * 0.3104856;
  b4 = 0.55000 * b4 + white * 0.5329522;
  b5 = -0.7616 * b5 - white * 0.0168980;
  pink = b0 + b1 + b2 + b3 + b4 + b5 + b6 + white * 0.5362;
  b6 = white * 0.115926;


An 'economy' version with accuracy of +/-0.5dB is also available.

  b0 = 0.99765 * b0 + white * 0.0990460;
  b1 = 0.96300 * b1 + white * 0.2965164;
  b2 = 0.57000 * b2 + white * 1.0526913;
  pink = b0 + b1 + b2 + white * 0.1848;



---
paul.kellett@maxim.abel.co.uk
http://www.abel.co.uk/~maxim/




and there is the “voss” or “gardner/voss” or “voss/mccartney” algorithm, which involves summing white noise generated at successively lower octaves. (mccartney’s innovation was to stagger the calculation of each octave, making the CPU load constant.) Robin Whittle has a good overview of these methods here.

this method from stefan stenzel innovates on the white-noise-octaves structure by upsampling the octaves with linear interpolation, in a highly efficient implementation. to my ears, the results are excellent. (downside is that it is a little harder to grok what is actually going on - at least for me.)

2 Likes