What curve does the soft clipping limiter uses?

Hi, everyone.

I’m using Audacity for a college class that requires us to apply some distortions on audio files. One of the distortions that I’m using is the soft clipping algorithm contained in the Limiter plugin.

My teacher asked me what’s the mapping used in the algorithm and so far I was not able to find an answer. Nothing is specified on the wiki, so I went to the source code, but had a hard time understanding exactly what was happening in the Nyquist script. It looks like a piecewise function, and it uses constants like 2/pi and (1 - 1/pi), but I wasn’t able to get past that.

Can someone please shed a light on what the soft clipping algorithm is doing? Was this method developed specifically for Audacity? The code for the plugin can be found here: https://github.com/audacity/audacity/blob/master/plug-ins/limiter.ny


It’s this:

From -0.5 to +0.5 it is linear.
The curves at the bottom / start and at the top / end are 1/8 cycle sine curves.

The signal shown in the screenshot above is used as a lookup table and applied to each sample in the sound being processed. Before being applied, it is scaled as required to clip at the selected level.

Thank you, steve!!