I am trying to write a simple live sine wave generator from scratch in Qt.
I try not to use any external APIs like ASIO or VST. And I want to generate new audio while playing. (As opposed to the Qt example, it just repeats some samples)
Qt only gives you a
QIODevice that you write data to at a fixed sample rate.
(If the fixed host sample rate is 44100Hz, you need to deliver exactly 44100 Samples a second)
I need an algorithm or design how to synchronize playback and generating of a sine wave.
Or, what is the general approach to audio generation?
Here are my tries to achieve that:
Two buffers, one gets written to, one gets played, and then swap, synchronized with mutexes
One buffer, that gets played and overwritten periodically
That was also supposed to be a sine wave, I tried to get the phase from the audio stream