Waveshaping is one of the basic ways of distortion synthesis. In its simplest form it works like any overdrive effect: by limiting a signal with a non-linear shaping function, additional harmonics are created.
Shaping Function¶
At the core of waveshaping is the transfer function or shaping function. This transfer function is not exactly what we know from signals and systems ($H(f)$), but a characteristic curve, defining a mapping of input values to output values.
For a linear system, the transfer function is the identity line:
If signals stay within the boundaries ($-1...1$ in this example), the operation is linear:
$$f(a) + f(b) = f(a+b)$$
Within the limits the operation does not alter an input signal at all:
The following example shows a simple tangential shaping function:
$$y=\mathrm{tanh}(g x)$$
For high pre-gain values, the function converges towards a step function and the output of a sinusoidal imput signal becomes a square wave. The following plot shows the shaping function for $g=4$:
Time Domain Comparison¶
In the time domain, the signal distortions are visible, but do not seem drastic:
Frequency Domain Comparison¶
However, a frequency domain plot reveals that a significant amount of harmonics have been added: