Stuck with a SynthEdit project?

Tag: Audio Aliasing

The Naïve Oscillator in SynthEdit.

So what is this Naïve Oscillator? I’m guessing you don’t know the term
(I didn’t know what it was for some time). Well it’s all to do with Aliasing, and the frequency limitations that apply to digital audio.
A “normal” oscillator in Synthedit is what is called “bandlimited” to prevent it producing frequencies above the Nyquist limit. The Naïve oscillator is not bandlimited and thus will produce aliasing (and lots of it!).
Note: The naive oscillator is also not very well optimised, so it’s a bit higher on CPU usage than the normal Oscillator module.

The difference between the Naive and normal stock oscillators.

Using the stock Frequency Analyser gives a good demonstration of the difference between the two oscillators.
The top oscillator is bandlimited, so has anti-aliasing built in.
Both Oscillators are generating a sawtooth at just over 1kHz. There is a noticeable amount of distortion and extra non-harmonically related frequencies generated at this frequency.
Notice all the extra frequencies below the 1kHz fundamental coming out of the Naïve Oscillator. What is happening here is that lots of high frequencies are being created by the sawtooth, but due to the limitations of the audio in Synthedit these higher frequencies are actually being folded back on themselves above the maximum audio frequency and appearing as spurious lower frequencies which are not harmonically related to the fundamental frequency.
You can see where the Bandlimiting starts to take affect; the level of the harmonics starts to dip, then suddenly cuts off, compare this with the Naïve Oscillator where the harmonics just keep on going…

Increase the Oscillator frequency to 8kHz and things will get even worse:

This diagram makes things a little clearer, the red dashed line shows the harmonics that have been “folded back” into lower frequencies, being above the maximum our digital audio can handle they aren’t ignored, but instead turned into an ugly sounding inharmonic mess.

Aliasing  and "folding back"

If you want to find out more try these articles:
https://www.metafunction.co.uk/post/all-about-digital-oscillators-part-1-aliasing-foldover
https://www.metafunction.co.uk/post/all-about-digital-oscillators-part-2-blits-bleps

SynthEdit:- Aliasing and distortion.

Audio Aliasing is an effect which occurs when converting an analogue signal into a digital one with an insufficient sampling frequency.
The result of this effect is that the high-frequency components of that analogue signal will not be correctly interpreted, and the digital signal will not be an accurate copy of the analogue one.
Analogue to Digital conversion.
When analogue signals are digitised and turned into digital signals, the analogue signal is sampled at regularly occurring points in time, or in other words, the instantaneous amplitude of the analogue signal is recorded to create a digital copy of the analogue signal.
This happens very quickly in audio signals, for example, CD audio is sampled at 44.1 kHz (44,100 samples per second).
Aliasing occurs when a signal is sampled at an insufficient rate. Two audio signals can become indistinguishable from each other once they have been sampled and converted– they have become aliases of each other.

The Nyquist sampling theorem states that:
“To avoid aliasing, the sampling frequency must be at least twice that of the highest frequency which is to be represented“. If we use the example of CD audio, a sampling frequency of 44.1 kHz means that the highest frequency which can be represented without aliasing is 22.05 kHz. For CD audio this is sufficient as the upper limit of human hearing is around 15 to 20 kHz depending on the individual.

Aliasing can occur either because the anti-alias filter in the A-D converter (or in a sample-rate converter) doesn’t have a steep enough roll-off, or alternatively because the system has been overloaded. Distortion caused by overloading the input or conversion circuitry is the most common source of aliasing, because overloads result in the generation of multiple high-frequency harmonics within the digital system itself after the anti-aliasing filtering.
Sampling images.
The sampling process is similar to a form of amplitude modulation in which the input signal frequencies are added to, and subtracted from the sample-rate frequency. In radio terms, the sum products are called the upper sideband and the subtracted products are called the lower sideband. In digital circles they are just referred to as the ‘images‘.
Unwanted Effects.
These images play no part in the digital audio process — they are essentially just a side-effect of sampling. However they must be kept well above the wanted audio frequencies so that they can be removed easily without affecting the quality of the required audio signals. This is where all the can trouble begin. The upper image isn’t really a problem – that’s easily filtered out, but if the lower one is too low in frequency, it will mix with the audio we do want and because the frequencies are similar, this will create ‘aliases‘ that cannot be removed.
Unwanted guests you can’t get rid of.
This is what the aliases turn into… that guest at the party who causes bad feelings and will not leave. Once aliasing effects are there there is no way you can filter them out without causing even more audio degradation.

Spectrum of aliasing signal images

Note that, unlike an analogue system, in which the distortion products caused by overloads always follow a normal harmonic series, and can even give quite a pleasant sound, (consider tape saturation on an old reel to reel recorder, or soft clipping in a valve amplifier) overloading, or incorrect clock frequencies in a digital system aliasing result in the harmonic series being “folded back or mirrored” on itself to produce audible signals that are no longer harmonically related to the source (they are referred to as “Inharmonics”).
In this very basic example, we have ended up with aliases at 2kHz and 18kHz that have no obvious musical relationship to the 10kHz source. This is why overloading a digital system sounds so nasty in comparison to overloading an analogue system.