In short: what kind of mathematical function was applied to this sine WAVE?

I am trying to implement my own distortion plugins. Amongst other things I have read several chapters of Will Pirkle's book ("Designing audio effect plugins in C++"). In the few examples there are in this book and that I could find on the internet, the distortion functions are always pretty straightforward. Here are few examples:

  1. y = 2*1/(1 + e**(-k*x)) - 1
  2. y = [(e**x - 1)(e + 1)]/[(e**x + 1)(e - 1)]
  3. y = tanh(kx) / tanh(k)y = arctan(kx) / arctan(k)
  4. y = sng(x) * [1 - e**(-abs(kx))] / [1 - e**(-k)]

I then decided to apply some distortions from Ableton Live(1) to a sine wave to see if I could replicate the distortion or get something similar to it.

Sound input:

C3 played with a sine oscillator

Sound output:

Overdrive plugin from Ableton Live applied to input

And none of the examples I found in the literature seem to work. Indeed, if we take equation 3 as an example, if the input is symmetrical at its peak like the sine wave is, then the output should also be symmetrical at its peaks. But that's not the case. To be more specific, for all the distortion examples above, if two samples have the same value, then the output for those two samples will also be the same.

As per my screenshot, we can see that is clearly not the case for that distortion as we can see that the symmetry around the peaks is broken. So my question is simple: what kind of DSP function is applied to the signal? I am speculating that it must have some kind of feedback to create this shape? Is there any examples you guys can refer me to?

To be clear, I'm not trying to replicate this exact distortion, I'm just trying to understand the kind of DSP functions that are used to implement those distortion plugins.

Thanks in advance for your help!

(1) Ableton Live is a DAW (digital audio work station) and is used to make music.

update: thanks all for the help, overwhelmed by how nice this community is :)

  • 3
    $\begingroup$ The short answer is that if it's not a simple waveshaper, it's often based on a circuit and/or physical model (e..g. tube amp, guitar pedal, vinyl, etc). David Yeh's thesis is a good place to start. $\endgroup$
    – datageist
    May 18, 2023 at 13:34
  • 2
    $\begingroup$ @datageist nice! I was about to start writing a comment about how I don't know how this is usually modelled in audio engineering, but a common way in communications engineering would be memory polynomials/Volterra series and finding optimal coefficients for that. But that thesis is actually domain-specific, so much more on point! $\endgroup$ May 18, 2023 at 14:57
  • 1
    $\begingroup$ Well, one thing though, from a practical point of view, is that 2009 was before neural networks / deep learning became the big and relatively solid research area that it's now, and in many fields of comms over nonlinear channels, Volterra Series approaches have proven to not be better but orders of magnitude harder to fit and compute in real-time than neural networks applied to the input sample stream. So, one might also look for how other people model e.g. amplifier nonlinearities with neural networks in literature. $\endgroup$ May 18, 2023 at 14:58
  • 1
    $\begingroup$ Marcus Müller is right about the neural networks. I am aware of the work of some researchers in Aalto University (Helsinki, Finland) that created amplifier simulations (and I believe they have tried with other audio effects) with neural networks and in their subjective tests showed that it was very difficult to differentiate between the real amp and the neural network simulated. I can't find the articles at the moment but I'll repost if I manage to do so. $\endgroup$
    – ZaellixA
    May 19, 2023 at 1:50

1 Answer 1


A simple and common way to generate distortion digitally is indeed to use a memoryless nonlinearity (such as the ones you mentioned), but just as a first step. The aim here is to perform some more or less soft clipping of the incoming waveform. But this is usually not enough to produce the desired sound. A very important step is the linear filtering after the nonlinearity. Clearly, the nonlinearity adds harmonics to the input signal, and the goal of the filtering is to shape the spectrum such that the harmonics don't sound too harsh. The usual filtering is some kind of lowpass filter with several resonances. In practice you don't want to have a lot of energy above about $8$ kHz in your spectrum. Very often you also attenuate low frequencies to avoid muddiness.

So the step you could add to your processing is a linear time-invariant filter. As an extremely simple example, I used a soft clipping non-linearity followed by a first-order recursive lowpass filter. As you can see in the figure below, the filtering has a severe impact on the shape of the waveform. In practice, the type of filtering usually has a more pronounced effect on the processed sound than the type of non-linearity.

enter image description here

Having said all that, nowadays the algorithms used in professional products are usually much more complex than the one just described. This paper gives a good overview of such methods.

  • 1
    $\begingroup$ This is pretty close, Matt. I would suggest flattening the sine more using a high-order smoothstep function. And then we need an LTI filter that has for its step response something like a critical or over-damped 2nd-order response: $$ y(t) = (e^{-t} - e^{-2t}) u(t) $$ It's possible that the OP's algorithm did zero-crossing detection and the output would look the same no matter what periodic waveform went in. $\endgroup$ May 18, 2023 at 18:03
  • 1
    $\begingroup$ Nice. One note to make here (more of an addition to your answer than anything else) is that very often nowadays most algorithms include an oversampling step before the processing and a downsampling step (to bring the audio back to its original rate) after the process. Before the latter, all high frequencies that would be aliased are filtered and the result is less aliasing in the final product. $\endgroup$
    – ZaellixA
    May 19, 2023 at 1:54

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.