Skip to content

DitherFract32

Overview

Adds dither to a fract32 signal

Discussion

This module generates uniformly distributed noise in fract32 format and then adds it to an input signal. This type of random noise is often added prior to quantization to change the characteristics of the quantization noise. The module can be configured to generate noise with a uniform distribution (ditherType=1), or a triangular distribution (ditherType=2). For a rectangular distribution, a single random value is used; for the triangular distribution, two uniformly distributed random numbers are added. Setting ditherType=0 causes the input to be passed unchanged to the output.

The shiftBits variable controls how many bits to the right each random value should be shifted prior to being added to the input. Keep in mind that the random values are generated to be full scale (+/-1) and should almost always be shifted to the right. If no shifting occurs with the triangular distribution then the values will often saturate.

Module Pack

Advanced

ClassID

classID = 1260

Type Definition

typedef struct _ModuleDitherFract32
{
ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
INT32 ditherType;                             // Controls the type of dither used by the module.  0 = no dither.  1 = rectangular distribution.  2 = triangular distribution
INT32 shiftBits;                              // Number of bits to shift random noise
UINT32 seed;                                  // Initial seed value for the random number generator
} ModuleDitherFract32Class;

Variables

Properties

Name Type Usage isHidden Default Value Range Units
ditherType int parameter 0 1 0:2
shiftBits int parameter 0 16 0:32
seed uint parameter 1 random value Unrestricted

Pins

Input Pins

Name in
Description audio input
Data type fract32
Channel range Unrestricted
Block size range Unrestricted
Sample rate range Unrestricted
Complex support Real

Output Pins

Name out
Description audio output
Data Type fract32

Matlab Usage

File Name: dither_fract32_module.m 
 M=dither_fract32_module(NAME) 
 Creates a modules which adds dither to a fract32 audio stream. 
 The module can be configured for rectangular or triangular 
 distribution.  Arguments: 
    NAME - name of the module. 

Copyright (c) 2026 DSP Concepts, Inc.