SoftClipFract32
Overview
Fract32 Soft clip in Fract32
Discussion
The soft clipper uses a combination of piecewise linear and non-linear functions. Threshold sets the beginning of the knee. The maximum output is always -6*guardbit dB. The knee is shorter when the threshold is closer to max output.
Type Definition
typedef struct _ModuleSoftClipFract32
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
FLOAT32 threshold; // Transition point between linear response and knee.
INT32 guardbit; // Linear threshold and max output are scaled by 2^(-guardbit) so output has 6*guardbit dB of headroom.
fract32 th; // Threshold in linear scale
fract32* lastIn; // Array of last input sample, one per channel.
fract32* lastOut; // Array of last output sample, one per channel.
FLOAT32* currentGain; // Array of soft clipper gain, one per channel.
} ModuleSoftClipFract32Class;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
threshold | float | parameter | 0 | -4 | -20:-0.5 | dB |
guardbit | int | parameter | 0 | 4 | 0:8 | linear |
th | fract32 | derived | 1 | 0.03943 | Unrestricted | |
lastIn | fract32* | state | 1 | [1 x 1] | Unrestricted | linear |
lastOut | fract32* | state | 1 | [1 x 1] | Unrestricted | linear |
currentGain | float* | state | 0 | [1 x 1] | -40:3 | linear |
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: soft_clip_fract32_module.m
M=soft_clip_fract32_module(NAME)
Creates a soft clipper module for use in Audio Weaver. The soft clipper
is realized using a piecewise function.
Arguments: clipping threshold in dB. When input signal is below the
threshold, the gain of the soft clipper is 0 dB.
Then as the input signal increases, the output approaches max value of
1.0. The soft clipper maintains the continuity of the piecewise
compression function at the threshold point.
NAME - name of the module.