## Re: Advanced Limiter

#####
Reply #7 –

For example, why isn't this size a percentage of the output buffer?

It's an even power of two, designed to be just enough to catch clipping ahead of time, without incurring noticeable latency. Or at least the last two parts are my take. I just know it's a power of two to speed up wrapping within the buffer's size, and also to deal with the exponential aspect.

It's not logarithmic, it steps back one sample, then doubles the step every time until it reaches the end of the buffer. The source code of the original version still exists if you can find any copies of the 0.8.3 SDK or older which included what was then foo_dsp_extra's source. Or, "Monkee Limiter".

The hard limiter is just:

static const float limiter_max = (float)0.9999;

static const float limiter_max_05 = (float)(limiter_max - 0.5);

if (val < -0.5)

val = (tanh((val + 0.5) / limiter_max_05) * limiter_max_05 - 0.5);

else if (val > 0.5)

val = (tanh((val - 0.5) / limiter_max_05) * limiter_max_05 + 0.5);

So, for every sample greater than ±0.5, scaling it down so 0.0 is 0.5 and 1.0 is clipping, feeding the result into hyperbolic tangent, which produces a slope that approaches but never reaches 1.0.

Definitely has more potential for distortion than the Advanced Limiter, but has no effect if the signal doesn't exceed ±0.5.