Mathematics in distortion effects

I have use the dsitoration effects in audacity, sounds pretty good. And I am very interested in “Cubic Curve (odd harmonics)” and “Expand and Compress”.
Can anyone help explain the principle of implementation in it? Or recommend some related information notes.
Thanks.

Audacity’s “Distortion” effect is a “waveshaper”.

Basically it maps sample values to new values depending on the value. For example, the “hard clipping” setting in pseudo code:

IF
    sample_value > positive_threshold
THEN
    sample_value = positive_threshold
ELSE IF
    sample_value < negative_threshold
THEN
    sample_value = negative_threshold
ELSE
    PASS  # use the original sample value

Notes:

  • As a point of interest, Audacity’s Distortion effect was originally implemented in Nyquist, using the SHAPE function.
  • Cubic formula: y = x - (x^3 / 3.0)

Cubic distortion generating odd (not even) harmonic (3kHz) …
toolchain

Now the bad news: in Audcaity3 if you try to insert text into a plugin,
(e.g. math formula or hex serial-number), some letters are do not appear,
and instead are misinterpreted by Audacity as keyboard shortcuts.

Is that a new / known issue?

This looks similar … Label loses focus when typing on Mac OS Ventura · Issue #3883 · audacity/audacity · GitHub
[ I’m getting it on Windows ].

Thanks for your reply.

This comes from “[sin(x)]^3 = 3/4sin(x) - 1/4sin(3x)” ?
if x = sin(x),
y = 3/4sin(x) + 1/12sin(3x)

toolchain-abc

NB: This Toolchain plugin does not work reliably in Audacity.