Hacker News new | ask | show | jobs
by Gordonjcp 1160 days ago
> However, digital synthesis does not require this sort of conception at all, and can be constructed without any summing of a harmonic series.

Yes, but you also cannot just make something that goes from -1 to 1 and then wraps back to -1 again, in a discrete-time (sampled) world.

You will get aliasing, because at some point your harmonic series will have partials that are noticeably large and exceed the Nyquist frequency, which will fold back into the output signal's spectrum. And, wouldn't you know it, except for a few very precise frequencies, those aliases will be inharmonic as all hell.

Here's an example (headphone warning - excessively loud) from a daft idea I had to implement a "virtual analogue" synth on an Arduino. Yes, one of the 8-bit ones, that can't do arithmetic.

https://raw.githubusercontent.com/ErroneousBosh/slttblep/mas...

The first sweep is generated with bandlimiting disabled, and you can hear the "swoopy" noises as the aliases slide up and down. The second sweep has some bandlimiting applied by "bending" the points where the signal resets to roughly correspond to a weighted sinc filter, eliminating (most of) the partials above Nyquist.

It uses 16-bit arithmetic on 8-bit lookup tables, and is output through an 8-bit PWM abused as a DAC, so it's not super clean, but it is at least not grossly incorrect.

You cannot filter the synthesized partials that go past Nyquist out after the signal has been generated, because the damage has been done.