PortAudio  2.0
Data Structures | Typedefs | Functions

Functions for generating dither noise. More...

#include "pa_types.h"

Go to the source code of this file.

Data Structures

struct  PaUtilTriangularDitherGenerator
 State needed to generate a dither signal. More...
 

Typedefs

typedef struct
PaUtilTriangularDitherGenerator 
PaUtilTriangularDitherGenerator
 State needed to generate a dither signal. More...
 

Functions

void PaUtil_InitializeTriangularDitherState (PaUtilTriangularDitherGenerator *ditherState)
 Initialize dither state. More...
 
PaInt32 PaUtil_Generate16BitTriangularDither (PaUtilTriangularDitherGenerator *ditherState)
 Calculate 2 LSB dither signal with a triangular distribution. Ranged for adding to a 1 bit right-shifted 32 bit integer prior to >>15. eg: More...
 
float PaUtil_GenerateFloatTriangularDither (PaUtilTriangularDitherGenerator *ditherState)
 Calculate 2 LSB dither signal with a triangular distribution. Ranged for adding to a pre-scaled float. More...
 

Detailed Description

Functions for generating dither noise.

Typedef Documentation

State needed to generate a dither signal.

Function Documentation

PaInt32 PaUtil_Generate16BitTriangularDither ( PaUtilTriangularDitherGenerator ditherState)

Calculate 2 LSB dither signal with a triangular distribution. Ranged for adding to a 1 bit right-shifted 32 bit integer prior to >>15. eg:

    signed long in = *
    signed long dither = PaUtil_Generate16BitTriangularDither( ditherState );
    signed short out = (signed short)(((in>>1) + dither) >> 15);
Returns
A signed 32-bit integer with a range of +32767 to -32768

References DITHER_SHIFT_, PaUtilTriangularDitherGenerator::previous, PaUtilTriangularDitherGenerator::randSeed1, and PaUtilTriangularDitherGenerator::randSeed2.

float PaUtil_GenerateFloatTriangularDither ( PaUtilTriangularDitherGenerator ditherState)

Calculate 2 LSB dither signal with a triangular distribution. Ranged for adding to a pre-scaled float.

    float in = *
    float dither = PaUtil_GenerateFloatTriangularDither( ditherState );
    // use smaller scaler to prevent overflow when we add the dither
    signed short out = (signed short)(in*(32766.0f) + dither );
Returns
A float with a range of -2.0 to +1.99999.

References DITHER_SHIFT_, PaUtilTriangularDitherGenerator::previous, PaUtilTriangularDitherGenerator::randSeed1, and PaUtilTriangularDitherGenerator::randSeed2.

void PaUtil_InitializeTriangularDitherState ( PaUtilTriangularDitherGenerator ditherState)