The original audio.c code just sampled the state of the 4 program flags 40K times /sec, added them together, and sent them to SDL as a mono bitstream.
I set up 4 separate digital low-pass filters, one per flag, then combine the filtered 1 & 2 into left audio channel, 3 & 4 into right, then feed that to SDL as a stereo stream
I also changed the timing. The original harmony code did 5714 samples/sec, so in order to properly reproduce the pitch, I do the same, oversampled by 4. 40K is very close, but it oversamples by a factor of 7 which is not useful without filtering.
Bill