For today’s article I’d like to take a look at wavefolding. For those who are unfamiliar, wavefolding is an interesting type of distortion that can be found in several notable analog synthesizer circuits. The general idea behind wavefolding distortion is that as the signal grows larger it eventually reflects over itself. There seems to be a lot of mystery about wavefolding in what I’ve found on the internet, so I’m hoping to clarify some things here by breaking down some typical digital wavefolding techniques, and then introducing a couple of my own modifications on the standard techniques.
Note that I won’t really be touching on analog wavefolding circuits in this post, for more information on that subject, I recommend this blog post by Keith McMillen as well as this DAFx paper from 2017 which provides an insightful discussion of the Buchla 259 wavefolder circuit.
As per usual, this article is also available as a Jupyter Notebook for the programmers out there.
Standard Digital Wavefolding
The typical method for implementing a digital wavefolding effect is to modulate the input signal by another wave, often a triangle or sine wave. This means that the static curves we’re used to looking at for nonlinear effects will be simple triangle or sine waves.
When we apply this simple wavefolding technique to an input sine wave, we get back the expected “folding” behavior.
Modified Wavefolding 1: Saturation
The first modification we’ll make to the traditional digital wavefolder is to sum the outputs of a saturating nonlinearity and a wavefolding nonlinearity. Although I haven’t compared the two on a mathematical level, I’ve found through my own (quite subjective) listening tests that this architecture sounds a little bit more similar to a typical analog wavefolder, especially for large amounts of folding.
The diagram above shows the signal flow for the saturating wavefolder, where the “WF” block denotes the wavefolding nonlinearity. For the gain “G”, I typically use somwhere between -0.5 and -0.1. Below we show the static curve and sine wave response for a saturating wavefolder with a hyperbolic tangent saturator, a sine wavefolder, and G=-0.2.
While the modified structure may seem only marginally different from the original wavefolder, watch how the response changes for a large input:
Modified Wavefolder 2: Feedback
Next, let’s modify our saturating wavefolder by adding a nonlinear feedback path.
This modification will add an interesting texture to our nonlinearity. In particular, it will add a little bit of movement, almost like a resonance, that reflects the behavior of the wavefolder. It’s a little bit difficult to describe, but an audio example will be provided later on.
Below we show the dynamic response of the saturating feedback wavefolder in which both the feedforward and feedback nonlinearities are tanh functions, the wavefolder is a sine wave function, and G = -0.5.
Wavefolders are notorious for having a pretty gnarly harmonic response, which can result in some serious aliasing distortion if not handled properly. First, let’s look at the harmonic response for the traditional digital wavefolder, for both sine and triangle waves.
So first off, note the shape of the harmonic structures for both wavefolders: in both cases the 5th harmonic is the most prominent, even more so than the fundamental. We also see that the triangle shape has an almost unbounded harmonic response, which looks like it might lead to a ton of aliasing. While I personally don’t like the triangle wavefolder very much, if you would like to use it I recommend using a method called BLAMP (I’m serious that is actually what it’s called) to “round” the corners of the triangle function. You can read more here.
Next let’s take a look at the harmonic response for the saturating wavefolder, again with sine wavefolding, tanh saturation, and G=-0.2.
Not too much of interest going on here, the harmonic response is almost indistinguishable from a standard tanh nonlinearity. Finally let’s examine the feedback saturating wavefolder, again with feedforward and feedback nonlinearities as tanh functions, the wavefolder as a sine wave function, and G = -0.5.
Here we see a much more rich harmonic response, with smoothly decaying harmonics going most of the way up the spectrum. Aliasing could be an issue here, but fortunately our feedback path introduces a little bit of an integrating effect that cancels out some of the highest frequency harmonics. I’ve found that 4x oversampling mitigates most aliasing artifacts from this system, but I typically use 8x just to be safe.
As usual, I’ve implemented the above wavefolding processors, along with variable feedforward and feedback gains, as an audio plugin (VST, AU). Feel free to checkout the source code on GitHub, and checkout a video demo on YouTube:
Thanks as always for taking the time to check out another episode of complex nonlinear audio signal processing. I hope you’ve been inspired to try our some wavefolding distortion of your own, perhaps experimenting with and improving on some of the architectures we’ve discussed here.
For next time, I may look at some nonlinear reverb effects, but I’m keeping my options open…