|
PortAudio 2.0
|
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"Go to the source code of this file.
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) |
| OceanWave * | InitializeWave (double SR, float attackInSeconds, float maxLevel, float positionLeftRight) |
| int | main (void) |
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.
Definition in file paex_ocean_shore.c.
| #define NEW_ROW_SIZE (12 + (8*rand())/RAND_MAX) |
Definition at line 362 of file paex_ocean_shore.c.
| #define PINK_MAX_RANDOM_ROWS (30) |
Definition at line 69 of file paex_ocean_shore.c.
| #define PINK_RANDOM_BITS (24) |
Definition at line 70 of file paex_ocean_shore.c.
| #define PINK_RANDOM_SHIFT ((sizeof(long)*8)-PINK_RANDOM_BITS) |
Definition at line 71 of file paex_ocean_shore.c.
| enum EnvState |
Definition at line 92 of file paex_ocean_shore.c.
| float GeneratePinkNoise | ( | PinkNoise * | pink | ) |
Definition at line 152 of file paex_ocean_shore.c.
| unsigned GenerateWave | ( | OceanWave * | wave, |
| float * | output, | ||
| unsigned | noOfFrames ) |
Definition at line 201 of file paex_ocean_shore.c.
| void InitializePinkNoise | ( | PinkNoise * | pink, |
| int | numRows ) |
Definition at line 137 of file paex_ocean_shore.c.
| OceanWave * InitializeWave | ( | double | SR, |
| float | attackInSeconds, | ||
| float | maxLevel, | ||
| float | positionLeftRight ) |
Definition at line 364 of file paex_ocean_shore.c.
| int main | ( | void | ) |
Definition at line 397 of file paex_ocean_shore.c.
| float ProcessBiquad | ( | const BiQuad * | coeffs, |
| float * | memory, | ||
| float | input ) |
Definition at line 189 of file paex_ocean_shore.c.