Overview
Wave shaper nonlinearity using either linear interpolation or math function
Discussion
The module implements arctangent wave shaping. The arctangent is a part of a family of functions called sigmoid functions. Sigmoid functions produce S-shaped curves. The amplitude transfer function of a vacuum tube generally resembles a sigmoid, so this function can be used to try to mimic a tube sound. With the arctangent function atan(kx), where k controls the amplitude of the input value and thus the amount of nonlinear processing applied. The exact equation is:
...
Optional: Wave shaper module using table lookup and linear interpolation.
Type Definition
Code Block |
---|
typedef struct _ModuleWaveShaperAtan { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure INT32 numStages; // The number of stages in series INT32 invStages; // Inverting or not inverting every other stage when cascaded FLOAT32 kPos; // Defines the amount of nonlinear processing for the positive half of the input signal FLOAT32 kNeg; // Defines the amount of nonlinear processing for the negative half of the input signal INT32 useTableLookup; // Shaping via lookup table FLOAT32 minX; // X value corresponding to the first table entry. FLOAT32 maxX; // X value corresponding to the last table entry. INT32 L; // Number of entries in the table. FLOAT32 divisor; // Precomputed constant = (L-1)/(maxX-minX) to eliminate division on the target. INT32 tableHeap; // Heap in which to allocate memory. FLOAT32* table_atan; // Array of arctan table values } ModuleWaveShaperAtanClass; |
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
numStages | int | parameter | 0 | 1 | 1:5 | |
invStages | int | parameter | 0 | 0 | 0:1 | |
kPos | float | parameter | 0 | 1 | 0.1:5 | |
kNeg | float | parameter | 0 | 1 | 0.1:5 | |
useTableLookup | int | parameter | 0 | 0 | 0:1 | |
minX | float | const | 1 | -5 | Unrestricted | |
maxX | float | const | 1 | 5 | Unrestricted | |
L | int | const | 1 | 64 | 2:1:8192 | |
divisor | float | const | 1 | 6.3 | Unrestricted | |
tableHeap | int | const | 1 | 2 | Unrestricted | |
table_atan | float* | parameter | 1 | [64 x 1] | Unrestricted |
Pins
Input Pins
Name: in
Description: Audio input
...
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: out
Description: Audio output
Data type: float
MATLAB Usage
File Name: wave_shaper_atan_module.m
...