A couple years ago, we set out to build a synth. We spent a ton of time focusing on automation, a good high resolution spectrum display, proper portamento, waveform warping, preset sharing, and a bunch of other features that we thought important. What we didn’t focus on? Proper anti-aliasing.
The result was a synth that had some killer new features, but frankly just didn’t sound as good as it should have. The waveforms were not bandwidth limited.
So, having finally come back around to the realization that it was time to upgrade the waveforms, we looked through the various ways to do this and settled on a very modern technique that used bandwidth limited steps (minBleps, for short), to construct proper bandwidth limited waveforms. What follows is a detailed explanation of our adventures in using this new technique, along with technical guidance for anyone hoping to do the same. Should you like to read the technical paper on this technique (by Eli Brandt of CMU), it is available here.
Additionally, should you care to see the code, we have created an open source variation of the juce plugin demo, available on github:
https://github.com/aaronleese/JucePlugin-Synth-with-AntiAliasing
Background – Aliasing & Bandwidth
Let’s start off by considering a square wave. Like any other real world signal, a square wave can be thought of as an infinite sum of sine waves. Adding them all up, you get a perfect square wave.
The first synths (additive synths), generally worked by summing up 8 or 10 sine waves to get something approximating a square wave. This is what we call “bandwidth limited”, meaning that the signal is made up of a finite number of sine waves.
Summing up sine waves however, is a fairly inflexible and non-causal (which will be discussed more later, but essentially means you can’t use this method for certain real time functions). We wanted a synth that was more versatile, and so we settled on the idea of creating a bandwidth limited subtractive synth using the minBlep method for antialiasing.
Hard Syncing and minBleps
Another feature that we became aware of and wanted to add to our synth was hard syncing; which, according to Sound on Sound journalist Gordon Reid, is the least understood feature for many users of a synthesizer [1].
Simply put, a hard synced synth is one in which one oscillator (the master) causes another (the slave) to reset. If should be clear by now what challenge this presents: namely, that every time the waveform resets it introduces a nonlinearity. This means that additive synths, especially if using pre-computed waves, will simply not do.
Enter the minimum phase band-limited step (or minBlep). The minBlep waveform is the real world version of a step; that is, it is the waveform that can move most quickly from one level to another without using any sine waves that are too high. This is important because “too high” sine waves (ones above the sampling rate) get reflected (aliased) to within the audible spectrum, and result in the bad sound artifacts we have mentioned.
The idea behind using a minBlep is that whenever a nonlinearity occurs, you add this waveform to the streaming audio (beginning exactly at the location of the nonlinearity), and effectively remove the higher frequency components of the step, while keeping the desirable ones.
Tuning the minBlep
We can of course, take this idea one step further, and generate a waveform which will limit the band to be below the sampling rate. In this way, we can tune up the number of harmonics we would like to use. You can think of this are harmonic depth.
Triangle Waves and Higher Order Nonlinearities
This is a great start, but in order to achieve a complete hard synced synth, we will need to consider higher order nonlinearities. Consider, for example, a triangle wave. The triangle does not have a primary nonlinearity like the square wave, but it does have an instant change in velocity (rate of change). Going immediately from a positive slope, to a negative one.
Just as the triangle wave is the integral of the square wave, one could expect adding the integral of the minBlep waveform to the triangle will correct the aliasing and remove the higher freq components.
The integral of the minBlep is usually referred to as the “bandwidth limited ramp”. It is important to remember that the ramp must be scaled so that the initial slope of the ramp matches the difference in slope across the nonlinearity.
The Hard Synced Sine
Having dealt now with primary and first order nonlinearities, we are in a position to generate the hard synced sine wave. Technically, the sine wave also contains a 2nd order nonlinearity (change in inflection), so we cannot perfectly correct. However, this technique leads to antialiasing which falls off at a reasonable 6dB per octave.
To properly remove higher order harmonics, we need to find both the change in value (think, position) and the change in delta (think velocity of change) at the nonlinearity where the hard synced sine resets. Once these values are determined, we scale the minBlep and bandwidth limited ramp appropriately, and add them to the sine at the position of the reset (where the hard sync occurs).
Implication of Real-Time Band Limiting
Finally, lets consider the larger implications of being able to limit bandwidth in real time. Specifically, note that with this technique we could effectively error correct skips within audio.
Here, for example, is a glitch plugin which constantly jumps around within an audio sample. Knowing exactly when the skip occurs, and being able to measure the size of the discontinuities (in both position and velocity), we can error correct in the same way as we did with the hard synced sine wave. Theoretically, we could use this technique on live streaming audio too (a project for another day).
Another great use of this technique is for time-based effects, like Flangers, Chorus, or Tremolo effects. Here we determine the exact position of the skip in the mod waveform, and then look to the audio for determining the magnitude of the skip. This is essentially skipping in audio (the delayed waveform which is used to create the effect).
Conclusion
We have found that there are indeed many uses for Eli Brandt’s minBlep method. We can use this technique to construct alias free synths, including ones capable of hard syncing. We can also use this technique for error correction in a variety of contexts, from effects to real time audio.
Some relevant links:
GitHub open source project
Technical paper by Eli Brandt