Download source code and executable program pinknoise.zip:
This C program generates octave-band or third-octave-band pink noise audio waveforms. The power spectral density of pink noise is inversely proportional to the frequency, giving a negative slope of 3 decibels per octave.
The program computes 2^19 = 524288 white Gaussian pseudorandom numbers, or about 12 seconds of audio at 44100 samples per second. The discrete Fourier transform of that time series is computed and weighted by a pink noise function. Contiguous octave or third-octave frequency bands from the resultant weighted spectrum are inverse transformed to generate band-limited noise. The rms amplitude level of the 16-bit PCM waveform is set to -15 db relative to full scale.
The output computer file contains the broadband pink noise followed by band-limited noise segments starting at the lowest band center frequency and proceeding to the highest frequency band. The 12-second segments are separated by 1 second of silence. There are 10 octave bands or 31 third-octave bands, depending on the setting of the compile-time macro THIRD_OCTAVE. Both versions of the executable program are provided in the distribution. Band edge frequencies and amplitude statistics are shown in the files pink1.txt, pink2.txt. These text files can be compared with the program printout to verify proper operation.
Files: