I have explored sound in both ZX Spectrum and C64 emulators, from a deliberately crude demo to buffered Z80 audio and native MacOS playback. These approaches connect to my work on direct hardware audio and my investigations of diagnosing audio distortion and audio quality limitations.
In a ZX Spectrum emulator sound-generation demo, I found the interesting aspect was the “very crude” way the sound was made.
The original @FlohOfWoe emulator I used had proper audio support: every time the Z80 is ticked, the audio output is sampled, put into a buffer, centered and converted into samples.
A callback can be registered to play such samples.
My C64 emulator with Kitty terminal output gained native audio support under MacOS, using the Core Audio API.
I live coded the audio support for the Kitty C64 emulator on my YouTube channel, in Italian with English subtitles.
I said, “in the next two days you'll see the other two episodes.”