I'm writing a simple synth in assembly as a learning project, and I'd like to implement a few more advanced features found on modern synths, namely the ADSR envelope and pulse width modulation using a sine wave. At the moment, I'm basically generating the samples by hand and pushing them to the audio out, which has a sample buffer and an interrupt it produces when the buffer gets near empty.
What I'm stuck on is how to generate a 'continuous' waveform. At the moment, I generate samples for a single instance of a wave (be it saw or pulse), and simply loop that one wave to generate continuous output. As you can imagine, that doesn't scale well to PWM and the ADSR envelope. I, therefore, need to generate the wave on demand, with potential adjustments to it on the fly, such as modulation of the pulse width or pitch (e.g. for legato), but I'm stumped as to how to represent that efficiently in memory, as well how to 'pause' the waveform generation when the buffer has been filled and 'resume' when the interrupt comes along.
I'm not seeking a solution so much as a nudge in the right direction of thinking :-)
Thanks!