Hacker News new | ask | show | jobs
by rerdavies 1281 days ago
Agree with all those who have raised the issue of problems with aliasing. Just to flush things out, it's worth mentioning what effect aliasing has on the quality of the audio output. Nobody seems to have address that issue yet.

Aliasing causes higher harmonics to reflect at the Nyquist sampling rate and be heard as a signal with lower frequency. e.g. a 25khz signal with a sampling rate of 24khz will end up sounding like a 23khz signal instead. A 26khz signal will sound like a 22khz signal. And so forth. Because there are exponentially more harmonics as frequency increases, aliased harmonics can end up reflecting a startling amount of energy into audio frequency ranges, even if the amplitude of each harmonic is much lower than the amplitude of the fundamental harmonic.

Because the harmonics are reflected, they no longer form a harmonic series, so they end up adding a metallic sound to the overall output signal. The sound of inharmonic aliased signals alone is not unlike the sound of striking a metal dinner plate with a spoon, or a copper pipe with a wrench. Not a pleasant sound.

We have very inexact vocabularies for describing sound. But clipped signals with heavy aliasing are usually described in terms like the following: "harsh", "metallic", "cold", "fizzy".

In fairness, this is a toy example. One would hope that in a mature ecosystem, those few who are capable of doing the very significant heavy math lifting required to implement better clipping will contribute components that can be shared and reused by everyone.

1 comments

You've done a fantastic job of describing what I couldn't put my finger on! One of the issues I had when developing this code was what I referred to as a "jarring" noise when distortion gain was turned up. It's like you describe: almost "metallic." I alluded to the "jarring" sound in the article, and it's great to know the culprit! There weren't a lot of repos, articles, or forum posts that had examples of solid, straightforward distortion implementations, and now I can see why.

Hopefully, we'll see someone get some code out there that helps clean this up!