BASS.NET API for the Un4seen BASS Audio Library

UtilsSampleDither Method

BASS.NET API for the Un4seen BASS Audio Library
Applies a dither to a single sample value.

Namespace:  Un4seen.Bass
Assembly:  Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax

public static double SampleDither(
	double sample,
	double factor,
	double max
)

Parameters

sample
Type: SystemDouble
The sample data to add a dither to (e.g. an 8- or 16-bit sample value as a double value).
factor
Type: SystemDouble
The bit depth factor for the dither (typically between 0.3 and 0.9).
max
Type: SystemDouble
The maximum sample data range (e.g. 256 for 8-bit samples or 32768 for 16-bit samples).

Return Value

Type: Double
The dithered sample value:
Remarks

Dithering adds a low level white noise to the sample data before truncating for the purpose of minimizing quantization error.

Dithering here is implemented as a triangular probability density function (TPDF), actually a factor-bit triangular dither.

All parameters here are implemented as double values for maximum precision and performance. However, you might also pass 8-bit(byte) or 16-bit(short) values and then simply cast back the return value.

See Also

Reference