Antialiasing a synth?

Hi, I’m fairly new to dsp and have only recently come across a problem unbeknownst to me called “Anti aliasing” which causes this problem:

this is the spectrum of a saw wave played on my synth at a very high frequency. As you can see the harmonics are “bouncing back” at Nyquist’s frequency and going back down, even below the fundamental. This is obviously not ideal and was wondering a good way of going about solving it.
I have seen very little on these forums about antialiasing which surprises me quite a bit.

Thanks in advance

The problem is actually not a problem caused by JUCE, so your best bet is to do some research on the matter using your search engine of choice.

Yeah I did not mean to imply that it was a problem with juce. However I am surprised there are nto more forum posts discussing this issue, as it seems to be a pretty fundamental problem in dsp.
How did you solve this problem with your synth?

Aliasing is one of the most common issues when working with non-sinusoidal/non-linear systems in DSP and is usually “fixed” by using some kind of oversampling.

1 Like

Oversampling is not an ideal choice for oscillators, though. Even large oversampling factors might not reduce aliasing enough but the CPU use will be multiplied by the oversampling factor.

For wavetable based oscillators, one approach is to have multiple wavetables for different pitch ranges. (Wavetables for higher note pitches would have less high frequency partials.)

For generating the classic simple synth waveforms (triangles, saws and squares), there are specialized techniques like minBlep.

3 Likes

Yeah after going through some different articles and papers, I think the approach I will take is a combination of MIP MAPs (which is what you’re describing) as it states in this paper:

and also limiting the modulation index for high frequencies.

2 Likes

I “cheated” using an approach of constant “hard/reset sync” and frequency, but not actual sample, oversampling.

You can find several aliased-suppressed oscillators in oscillators.lib in the Faust Libraries distribution

For example, search oscillators.lib for “Bandlimited Sawtooth”, which defines os.sawN(freqInHz) among other functions. Integrating Faust in JUCE is described at

https://faustdoc.grame.fr/workshops/2020-04-10-faust-juce/

4 Likes

I dealt with this based on this blog post from Nigel Redmon about oscillator aliasing.