|
PortAudio 2.0
|
Functions for generating dither noise. More...
Macros | |
| #define | PA_DITHER_BITS_ (15) |
| #define | DITHER_SHIFT_ ((sizeof(PaInt32)*8 - PA_DITHER_BITS_) + 1) |
| #define | PA_FLOAT_DITHER_SCALE_ (1.0f / ((1<<PA_DITHER_BITS_)-1)) |
Functions | |
| void | PaUtil_InitializeTriangularDitherState (PaUtilTriangularDitherGenerator *state) |
| Initialize dither state. | |
| PaInt32 | PaUtil_Generate16BitTriangularDither (PaUtilTriangularDitherGenerator *state) |
| 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: | |
| float | PaUtil_GenerateFloatTriangularDither (PaUtilTriangularDitherGenerator *state) |
| Calculate 2 LSB dither signal with a triangular distribution. Ranged for adding to a pre-scaled float. | |
Functions for generating dither noise.
| #define DITHER_SHIFT_ ((sizeof(PaInt32)*8 - PA_DITHER_BITS_) + 1) |
Referenced by PaUtil_Generate16BitTriangularDither(), and PaUtil_GenerateFloatTriangularDither().
| #define PA_DITHER_BITS_ (15) |
| #define PA_FLOAT_DITHER_SCALE_ (1.0f / ((1<<PA_DITHER_BITS_)-1)) |
| 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);
References DITHER_SHIFT_, PaUtilTriangularDitherGenerator::previous, PaUtilTriangularDitherGenerator::randSeed1, and PaUtilTriangularDitherGenerator::randSeed2.
Referenced by ShowDitherDistribution().
| 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 );
References DITHER_SHIFT_, PaUtilTriangularDitherGenerator::previous, PaUtilTriangularDitherGenerator::randSeed1, and PaUtilTriangularDitherGenerator::randSeed2.
| void PaUtil_InitializeTriangularDitherState | ( | PaUtilTriangularDitherGenerator * | state | ) |
Initialize dither state.
References PaUtilTriangularDitherGenerator::previous, PaUtilTriangularDitherGenerator::randSeed1, and PaUtilTriangularDitherGenerator::randSeed2.
Referenced by main(), PaUtil_InitializeBufferProcessor(), and ShowDitherDistribution().