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
Code Block |
---|
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
...
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
...