Complex Nonlinearities Epsiode 2: Harmonic Exciter

Implementation: Level Detector

For the level detector part of this system, you have a lot of options. For instance you could start with a level detection scheme similar to one you might use in a compressor or gate effect, with parameterized attack and release characteristics (for more information, see here). In this implementation, I will use a somewhat simpler scheme: a rectifying nonlinearity followed by a lowpass filter.

Rectifying Nonlinearity

The idea of a rectifying nonlinearity is to take a signal that has both positive and negative values, and and transform it into one that contains only positive values. Here I’ll examine three common rectifying nonlinearities:

  1. Ideal Half Wave Rectifier: Similar to the Full Wave Rectifier, the positive part of the signal is unchanged, but for the Half Wave Rectifier, the negative part of the waveform is set to zero.
  2. Schockley Diode: A diode is a circuit element that is often used in rectifying circuits. For our purposes, we can think of it as a less ideal Half Wave Rectifier. For a mathematical treatment of Schockley Diodes, see here.

Lowpass Filter

The lowpass filter used in a level detector typically has a pretty low cutoff frequency. I often use a cutoff frequency somewhere around 10 Hz. I won’t discuss the technicalities of creating a lowpass filter here, but more information can be found in Julius Smith’s Introduction to Digital Filters.

Level Detector Example

Now let’s take a look at how the various level detectors handle a typical audio signal. Below we see the response of three level detectors, each using a different rectifying nonlinearity, and each using a first-order lowpass filter with a cutoff frequency at 10 Hz.

Implementation: Nonlinearity

For the nonlinearity used in an exciter, it is typical to use a saturating nonlinearity: that’s a nonlinearity that approaches constant output as the input gain grows large. I’ll show three options here (hard clipper, soft clipper, hyperbolic tangent), but feel free to experiment and try your own things!

Putting It All Together

Now let’s go ahead and connect these elements as shown by the diagram above. Below I’ll show the static curve and harmonic response for a 100 Hz sine wave, for an exciter with a diode rectifier, 10 Hz Lowpass Filter, and hyperbolic tangent nonlinearity.


Doing a complete analysis of the harmonic response for a nonlinearity as complex as this would be quite complex, the interested reader is encouraged to see Chapter 2 of a recent dissertation by Francois Germain. Through my own more empirical testing, I’ve found that oversampling by 8x is sufficient to eliminate aliasing artifacts down to ~100 dB.


To demonstrate this nonlinearity in a more realistic scenario, I have developed an audio plugin (VST, AU) that implements all of the options discussed above, as well as a variable filter frequency for the level detector, and drive level for the exciter overall. The source code for the plugin is available on GitHub. A video demo can be seen below.


Thanks for reading through another episode of this recurring series! I hope this article has helped inspire some ideas for cool sounds that you can make with your own DSP. For next time, I’m hoping to have a generalized, non-physical model of one of the coolest and most complex nonlinearities out there: hysteresis.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store