I am reading Audio effects: theory, implementation and application by Joshua D. Reiss and Andrew McPherson.

They explain that, in the simplest case with just a hard cutoff threshold, you have a piecewise linear equation

$$y_G = \begin{cases} x_G & x_G <T\\ \frac{x_G -T}{R} + T & x_G \geq T \end{cases} $$ with a corresponding diagram like

enter image description here

However, in many cases, you may not want this hard cutoff. You may want it to be softer like this

enter image description here

To do this, Reiss proposes the following formula

enter image description here

I found a PDF of a presentation he did where he called this "second order interpolation", but I have no idea what that means other than I think it's second order because of the quadratic terms in this version.

How does Reiss derive the middle formula in this piecewise equation?



2 Answers 2


The value $T$ for threshold is clear I think. It determines at what value $x_G$ the knee happens to be.

The influence of the values $W$ and espescially $R$ where a bit less clear to me. So I played around iterating several values. Here is the result for T=2: Animation of different parameters for the pitch and soft knee width

Now for the cases $W>0$ where we get a soft knee instead of a cut. If you look closely at the equation for the part for the soft knee one can see that it is a summation of three curves.

$$x_G+(\frac{1}{2WR}-\frac{1}{2W})\cdot (x_G-T+W/2)^2$$

  1. The first part is simply $y_g=x_g$ which is a line with pitch 1.
  2. The second part is a parabola in vertex-form: $y_G=\frac{1}{2WR}\cdot (x_G-T+W/2)^2$ A parabola is defined by its vertex and by a facor defining whether it opens to the top or bottom and whether it is compressed or stretched Parabola in vertex form. That one is $(T-W/2|0)$. So the vertex of the parabola is defined as the half width of the soft knee to the left side of the threshold $T$. If $\frac{1}{2WR}$ is bigger than $0$ it opens to the top and otherwise to the bottom. If $\frac{1}{2WR}$ is bigger than $1$ it is stretched while if it is between $0$ and $1$ it is compressed.
  3. The third part also is a parabola: $y_G=\frac{-1}{2W}\cdot (x_G-T+W/2)^2$ Here the vertex is the same as for 2: $(T-W/2|0)$. However as the factor this time is $\frac{-1}{2W}$ it is flipped and opens to the bottom fot positive $W$.

So for the case $T=2$, $R=20$ and $W=2$ we get: Total Soft Knee Curve

Zooming in on the soft knee area: Soft Knee Area

This part is the summation of the 3 described parts: 3 parts of soft knee area

In order to achieve a continious function the derivatives of the soft knee function has to match the other two parts.

  1. The part left of the beginning of the soft knee part is defined by $y_G=x_G$. So the derivative at point $p1$ is simply a constant $1$.
  2. The part right of the soft knee part is defined by $\frac{1}{R} x_G + (T-\frac{T}{R})$. The derivative is simply $\frac{1}{R}$. So the derivative at point $p2$ is simply the constant $\frac{1}{R}$.

Now we can check whether the function for the soft knee part matches those values at point $p1$ and $p2$.

Total soft knee function with points p1 and p2

The derivative of the soft-knee function is: $$\frac{dy_G}{dx_G}=1+(\frac{1}{WR}-\frac{1}{W})\cdot (x_G-T+W/2)$$

This function now has to be evaluated at point $p1=T-W/2$ and $p2=T+W/2$. Doing so matches exactly the two values $1$ at $p1$ and $\frac{1}{R}$ at $p2$.


If you look at the formula and plot it, you get what you see in the other link on dsp.ee. But if you add the inflexion points and plot the consituent functions, it should become more clear:


The function would have been a linear one, with two slopes, but between the points defined by $T-W/2$ and $T+W/2$, there is a curve uniting the two segments. This means that the conditions become:

  • a simple, quadratic formula (to avoid too much computation)
  • the function's value at the first point should be equal to the point, itself, and
  • the derivatives at those points should be the actual slopes

With these, there are many ways to interpolate, so I can't say exactly how they did, but these must have been their starting points.

For example, considering two slopes of $3/4$ and $1/4$ at $[-1,1]$, the quadratic function $f(x)=ax^2+bx+c$ that would unite those would have to have:

$$\left\{ \begin{aligned} f'(-1)&=2a(-1)+b&=\dfrac34 \\ f'(1)&=2a(1)+b&=\dfrac14 \end{aligned}\tag{1} \right.$$

The derivative makes $c$ disappear, but its value at $-1$ is $3/4$, so the solving the equations above results in the function:


and this is how it looks like:


The slopes at $[-1,1]$ are a match, which means the two slopes are now connected by a quadratic formula. The whole graph would be, from left to right: the red slope until $-1$, then the quadratic blue until $1$ and then the green slope; just like in the 1st picture.

I'll add that you can go the other way, just as well: from the derivative, up.

You know that the signal has a slope in the beginning, and one at the end which means that their derivatives give you fixed values (in the example above they were $3/4$ and $1/4$). Uniting the points will be a slope of the form $ax+b$, as seen in (1), starting from $-1$ with the value $3/4$, and ending up at $1$ with $1/4$. Since it's a line, it will pass through the middle point, $m$, and it will have a slope $s$, both given by:

$$\begin{align} m=\dfrac{\dfrac14+\dfrac34}{2}&=\dfrac12 \\ s=\dfrac{\dfrac14-\dfrac34}{2}&=-\dfrac14 \\ \Rightarrow\quad g(x)=m+sx&=\dfrac12-\dfrac14x\tag{3} \\ \end{align}$$


Integrate this to get the quadratic, to which you add the constant term $3/4$ -- the value of the function at $-1$:


(2) and (4) are the same. q.e.d.

  • $\begingroup$ Added the reverse way, both are valid. $\endgroup$ Mar 4, 2021 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.