But we can see the output is a bit glitchy, mainly because phase is reset between notes. It takes ten times as much time to build a wave than play it! But yhe code is in that previous link.Here is another ditty composed on my spread sheet. Sounds nasty but has a nice beat.
I collect the output pcm values in a test buffer, and I can change the resolution. So the sound below is much longer and he beatsd are visibler.