paex_pink.c File Reference
Example programs demonstrating PortAudio usage

Generate Pink Noise using Gardner method. More...

`#include <stdio.h>`
`#include <math.h>`
`#include "portaudio.h"`

Go to the source code of this file.

## Data Structures

struct | PinkNoise
struct | paTestData

## Macros

#define | PINK_MAX_RANDOM_ROWS (30)
#define | PINK_RANDOM_BITS (24)
#define | PINK_RANDOM_SHIFT ((sizeof(long)*8)-PINK_RANDOM_BITS)
#define | PINK_MEASURE
#define | PINK_TEST

## Functions

void | InitializePinkNoise (PinkNoise *pink, int numRows)
float | GeneratePinkNoise (PinkNoise *pink)
int | main (void)

## Variables

float | pinkMax = -999.0
float | pinkMin = 999.0

## Detailed Description

Generate Pink Noise using Gardner method.

Optimization suggested by James McCartney uses a tree to select which random value to replace.

            x x x x x x x x x x x x x x x x
            x   x   x   x   x   x   x   x
            x       x       x       x
             x               x
               x

Tree is generated by counting trailing zeros in an increasing index. When the index is zero, no random number is selected.

Author
  Phil Burk http://www.softsynth.com

Definition in file paex_pink.c.

## Macro Definition Documentation

## PINK_MAX_RANDOM_ROWS

#define PINK_MAX_RANDOM_ROWS (30)

Definition at line 61 of file paex_pink.c.

## PINK_MEASURE

#define PINK_MEASURE

Definition at line 106 of file paex_pink.c.

## PINK_RANDOM_BITS

#define PINK_RANDOM_BITS (24)

Definition at line 62 of file paex_pink.c.

## PINK_RANDOM_SHIFT

#define PINK_RANDOM_SHIFT ((sizeof(long)*8)-PINK_RANDOM_BITS)

Definition at line 63 of file paex_pink.c.

## PINK_TEST

#define PINK_TEST

Definition at line 156 of file paex_pink.c.

## Function Documentation

## GeneratePinkNoise()

float GeneratePinkNoise | ( | PinkNoise * | pink | ) |

Definition at line 113 of file paex_pink.c.

## InitializePinkNoise()

void InitializePinkNoise | ( | PinkNoise * | pink,
|  | int | numRows
| ) |  |

Definition at line 92 of file paex_pink.c.

## main()

int main | ( | void |  | ) |

Definition at line 208 of file paex_pink.c.

## Variable Documentation

## pinkMax

float pinkMax = -999.0

Definition at line 108 of file paex_pink.c.

## pinkMin

float pinkMin = 999.0

Definition at line 109 of file paex_pink.c.