Libfmsynth: a C library which implements an FM synthesizer
github.com
github.com
Originally, this synth was designed for a demoscene 4k intro, which was never finished. It was originally implemented with 16.16 fixed point arithmetic using legacy x86 assembly abusing one byte instruction encodings (e.g. using the AX part of RAX as the .16 fractional part). Some of the design decisions of the size-optimized hand-written assembly synth are still visible in the original code.
The original assembly implementation is buried somewhere deep in my hard disk.
[0] https://github.com/rikusalminen/jamtoysynth/blob/master/src/...
But it sounds alright and was easy to implement, I can see why it's popular.
One question I have is how difficult it would be to adapt a soft synth like this to also be able to produce the kinds of sounds you would get from a SID (from the C64 etc). My understanding of waveform synth is very limited, but it has always struck me how different all synthesizers (hardware and software) always sounded so different from SID chiptunes. Probably there's some analog effects going on there that are hard to reproduce mathematically?
Yes, exactly. The SID chip is a pretty complex analog synthesizer and it was made using less-than-perfect manufacturing processes, making some chips sound better than others. The SID has very nice analog filters that are not trivial to emulate with digital signal processing. Additionally, there were lots of ugly tricks that abused the SID chip, such as making sounds by emitting a "all ones" full-blast signal and then cranking the volume of the mixer circuit up and down to produce a fake pcm sound.
My best understanding is that a "normal" audio synthesizer (such as this one I believe) is doing computation at the same rate as audio output rate (typically 44 or 48 kHz). SID software emulators run internally at a much higher sample rate (hundreds of kHz) in order to emulate the analog circuitry.
Emulating it digitally is not just a matter of replicating the functionality of the circuitry, but also taking in account all the analog phenomena. It's much easier to model something like a Yamaha-style FM chip you can find in AdLib or early SoundBlaster cards.
Additive would generate sounds without any sort of time series "filter", and would attenuate the sine series before generating them.
For the SID, there's probably just not enough engineering going into emulation, as enthusiast prefer the original experience anyway.
[1] you might enjoy the talk Elements of chip music by Linus Akesson: <https://www.linusakesson.net/music/elements/index.php>