Trammell Pink Noise (C++ class)

Type : pink noise generator
References : Posted by dfl at ccrma dot stanford dot edu
Code :
#ifndef _PinkNoise_H
#define _PinkNoise_H

// Technique by Larry "RidgeRat" Trammell 3/2006
// http://home.earthlink.net/~ltrammell/tech/pinkalg.htm
// implementation and optimization by David Lowenfels

#include <cstdlib>
#include <ctime>

#define PINK_NOISE_NUM_STAGES 3

class PinkNoise {
public:
  PinkNoise() {
  srand ( time(NULL) ); // initialize random generator
    clear();
  }

  void clear() {
    for( size_t i=0; i< PINK_NOISE_NUM_STAGES; i++ )
      state[ i ] = 0.0;
    }
    
  float tick() {
    static const float RMI2 = 2.0 / float(RAND_MAX); // + 1.0; // change for range [0,1)
    static const float offset = A[0] + A[1] + A[2];

  // unrolled loop
    float temp = float( rand() );
    state[0] = P[0] * (state[0] - temp) + temp;
    temp = float( rand() );
    state[1] = P[1] * (state[1] - temp) + temp;
    temp = float( rand() );        
    state[2] = P[2] * (state[2] - temp) + temp;
    return ( A[0]*state[0] + A[1]*state[1] + A[2]*state[2] )*RMI2 - offset;
  }

protected:
  float state[ PINK_NOISE_NUM_STAGES ];
  static const float A[ PINK_NOISE_NUM_STAGES ];
  static const float P[ PINK_NOISE_NUM_STAGES ];
};

const float PinkNoise::A[] = { 0.02109238, 0.07113478, 0.68873558 }; // rescaled by (1+P)/(1-P)
const float PinkNoise::P[] = { 0.3190,  0.7756,  0.9613  };

#endif

Comments
from : ltramme1476[AT]earthlink[DOT]net
comment : Many thanks to David Lowenfels for posting this implementation of the early experimental version. I recommend switching to the new algorithm form described in 'newpink.htm' -- better range to 9+ octaves, better accuracy to +-0.25 dB, and leveled computational loading. So where is MY submission to the archive? Um... well, it's coming... if he doesn't beat me to the punch again and post his code first! -- Larry Trammell (the RidgeRat)

from : inb[DOT]la[DOT]n[DOT]c[DOT][AT]youtube[DOT]bxox[DOT]info
comment : [b]Òèíåäîë Êðåì Îò Ãðèáêà Íà Íîãàõ, Ïàëüöàõ, Íîãòÿõ [/b] Íå çàñòàâëÿåòå ãäå êóïèòü Tinedol ùåë÷îê îò âîçðàñòà â Ìîñêâå. Íå ñëåäóåò õîäèòü áîñèêîì ïî îáùåñòâåííûì ìåñòàì è ïëÿæàì, òàê êàê â ãîðÿ÷åì âëàæíîì ïåñêå ìîãóò íàõîäèòüñÿ ÷àñòè÷êè êîæè, çàðàæåííûå ãðèáêîì.  äàííîì ñëó÷àå ïîêàçàíî ïðèìåíåíèå ñóñïåíçèè Öèíäîë, êîòîðóþ ïðîñòî íàíîñÿò íà ïîðàæåííûå ó÷àñòêè êîæè íåñêîëüêî äíåé, äî íîðìàëèçàöèè ñîñòîÿíèÿ. Çóä ïðîø¸ë óæå ÷åðåç íåñêîëüêî äíåé, ÷åðåç íåäåëþ êîæà ñòóïíåé áûëà çäîðîâîé è ìÿãêîé. Êîãäà êóïèë Òèíåäîë êðåì íà÷àë çàáûâàòü ïðî ýòè íåïðèÿòíîñòè. Êîãäà â íåêîòîðûõ ïðåïàðàòàõ òóàëåò ñïîðîâ, ïîñëå ÷åãî ãðèáîê ñîâñåì èñ÷åçàåò, òðåñêàåòñÿ âîäíûé áàëàíñ. Ïëåñíåâîé ãðèáîê ïîðàæàåò íîãòè, îáðàçóÿ íà íèõ ðàçíîöâåòíûå òî÷êè è ïÿòíà. Ïîäöåïèë ãðèáîê â áàññåéíå. Èìåííî ïîýòîìó ëå÷èòü ãðèáîê ñëåäóåò ïðè âîçíèêíîâåíèè ïåðâûõ ïðèçíàêîâ. Ïî ýòîé ïðè÷èíå ïðèìåíåíèå êðåìà Òèíåäîë ñëåäóåò ñ÷èòàòü îòëè÷íûì âèäîì ëå÷åíèÿ è ïðîôèëàêòèêè ðàçëè÷íûõ çàáîëåâàíèé êîæè íîã. Òèíåäîë ïîìîæåò áûñòðî ñïðàâèòüñÿ ñ ãðèáêîì ñòóïíåé è íîãòåé. Òèíåäîë îò ãðèáêà êóïèòü â ñåðäîáñêå. Ïñèõîëîãèþ Òèíåäîë ðåàëüíî ðóêîâîäèò. Ó âàñ åñòü ñèñòåìà âûðåçàòü êðåì Òèíåäîë îò îñòåîïîðîçà ïî áðþøíîé ñòåíêå. [b]Ïåðåéòè íà ñàéò:[/b] http://tinedol.bxox.info/