PortAudio  2.0
Data Structures | Macros | Enumerations | Functions
paex_ocean_shore.c File Reference

Generate Pink Noise using Gardner method, and make "waves". Provides an example of how to post stuff to/from the audio callback using lock-free FIFOs implemented by the PA ringbuffer. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include "portaudio.h"
#include "pa_ringbuffer.h"
#include "pa_util.h"

Data Structures

struct  PinkNoise
 
struct  BiQuad
 
struct  OceanWave
 
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 NEW_ROW_SIZE   (12 + (8*rand())/RAND_MAX)
 

Enumerations

enum  EnvState { State_kAttack, State_kPreDecay, State_kDecay, State_kCnt }
 

Functions

void InitializePinkNoise (PinkNoise *pink, int numRows)
 
float GeneratePinkNoise (PinkNoise *pink)
 
unsigned GenerateWave (OceanWave *wave, float *output, unsigned noOfFrames)
 
float ProcessBiquad (const BiQuad *coeffs, float *memory, float input)
 
OceanWaveInitializeWave (double SR, float attackInSeconds, float maxLevel, float positionLeftRight)
 
int main (void)
 

Detailed Description

Generate Pink Noise using Gardner method, and make "waves". Provides an example of how to post stuff to/from the audio callback using lock-free FIFOs implemented by the PA ringbuffer.

    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 Robert Bielik

Macro Definition Documentation

#define NEW_ROW_SIZE   (12 + (8*rand())/RAND_MAX)

Referenced by InitializeWave().

#define PINK_MAX_RANDOM_ROWS   (30)
#define PINK_RANDOM_BITS   (24)

Referenced by InitializePinkNoise().

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

Referenced by GeneratePinkNoise().

Enumeration Type Documentation

enum EnvState
Enumerator
State_kAttack 
State_kPreDecay 
State_kDecay 
State_kCnt 

Function Documentation

float GeneratePinkNoise ( PinkNoise pink)
unsigned GenerateWave ( OceanWave wave,
float *  output,
unsigned  noOfFrames 
)
void InitializePinkNoise ( PinkNoise pink,
int  numRows 
)
OceanWave* InitializeWave ( double  SR,
float  attackInSeconds,
float  maxLevel,
float  positionLeftRight 
)
int main ( void  )
float ProcessBiquad ( const BiQuad coeffs,
float *  memory,
float  input 
)