code: def iterpink(depth=20):
      
      values = numpy.random.randn(depth)
      smooth = numpy.random.randn(depth)
      source = numpy.random.randn(depth)
      sumvals = values.sum()
      i = 0
      while True:
          yield sumvals + smooth[i]
  
          # advance the index by 1. if the index wraps, generate noise to use in
          # the calculations, but do not update any of the pink noise values.
          i += 1
          if i == depth:
              i = 0
              smooth = numpy.random.randn(depth)
              source = numpy.random.randn(depth)
              continue
  
          # count trailing zeros in i
          c = 0
          while not (i >> c) & 1:
              c += 1
  
          # replace value c with a new source element
          sumvals += source[i] - values[c]
          values[c] = source[i]
docs: Generate a sequence of samples of pink noise.
  
      pink noise generator
      from http://pydoc.net/Python/lmj.sound/0.1.1/lmj.sound.noise/
  
      Based on the Voss-McCartney algorithm, discussion and code examples at
      http://www.firstpr.com.au/dsp/pink-noise/
  
      depth: Use this many samples of white noise to calculate the output. A
        higher  number is slower to run, but renders low frequencies with more
        correct power spectra.
  
      Generates a never-ending sequence of floating-point values. Any continuous
      set of these samples will tend to have a 1/f power spectrum.