Hacker News new | ask | show | jobs
by atoav 956 days ago
The typical way FM synths (and for example function generators) generate a sine wave would be DDS (Direct digital synthesis).

You basically just have an array with all the values of a sine inside (or a quarter of a sine if you want to save memory) and then you jump through that array based on a phase accumulator (basically a counter). The amount by which you increment that phase accumulator (=phase step) determines the pitch of the resulting sine wave that this lookup gives you. So you basically add that phase step repeatedly and read out the current sine value at the current phase accumulator/index with a timer interrupt. Th

This operation is quite cheap, I once made a osciallator with 9 of these on an Arduino Nano (fixed point numbers tho).

Now the clou is that you could just add some amount of the result of another of those sine lookups to the phase accumulator, which results in the typical FM sound. Technically this is actually phase modulation, but hey technically the most famous FM synth uses also phase modulation.