Gin
Loading...
Searching...
No Matches
PinkNoise Class Reference

Pink noise generator using the Voss-McCartney algorithm. More...

#include <gin_noise.h>

Public Member Functions

 PinkNoise ()
float nextSample ()

Detailed Description

Pink noise generator using the Voss-McCartney algorithm.

PinkNoise produces random samples with a 1/f frequency spectrum (power decreases 3dB per octave). This implementation uses the Voss-McCartney approximation with a middle square Weyl PRNG and octave-sequencing lookup table for efficiency.

Pink noise characteristics:

  • 1/f power spectrum (3dB/octave roll-off)
  • Equal energy per octave
  • More natural-sounding than white noise
  • Efficient Voss-McCartney approximation

Implementation details:

  • Uses 9 octave bands for frequency spectrum shaping
  • Middle square Weyl PRNG for random number generation
  • Lookup table for determining which octave to update
  • Very fast execution suitable for real-time audio

Usage:

PinkNoise noise;
// In audio processing loop
for (int i = 0; i < numSamples; ++i)
{
float sample = noise.nextSample();
audioBuffer[i] = sample;
}
PinkNoise()
Definition gin_noise.h:127
float nextSample()
Definition gin_noise.h:138

LICENSE: Copyright 2020 Thomas Merchant

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

See also
WhiteNoise

Constructor & Destructor Documentation

◆ PinkNoise()

PinkNoise::PinkNoise ( )

Member Function Documentation

◆ nextSample()

float PinkNoise::nextSample ( )

The documentation for this class was generated from the following file: