Produce musical signal from instantaneous frequency I'm implementing the Yin Algorithm in Python so as to extract the pitch of my voice when whistling or humming. My goal is to produce the Gate (Envelop Control) and CV (Pitch Control) signals which can be inputted to an analog synth. I'd also like to write a software synth which takes theses signals as input. That way I can play the synth with my voice.
The top graph below is the output of the YIN algorithm when I whistled a few notes:

I then tidied this up with a low pass filter to produce the signal in the second graph. Finally and perhaps naively,  I produced the third signal as follows:
from scipy.io.wavfile import write
sr = 16000 # sample rate
f = [518.8087307738297, 518.9079938888592, 518.9177212823167, 519.8298830180304, 522.3027794382949, 523.8695096842832, 524.859458031283, 525.4703986196301, 525.4431662533539, 525.6859351990167, 525.6523745060124, 525.9697551477367, ...]
out = [math.cos(2*math.pi*f[i]*(i/sr)) for i in range(len(f))] 

So in other words:
cos(2 pi f t)

where f(t) is the signal in the second graph. I expected this to produce a signal similar to that of my whistling recording put with constant amplitude. However, I get a really chirpy sounding signal that doesn't remind me at all of my original recording. If I use the first signal in my graph as f(t) I get noise when I apply it to cos(2 pi f t). What am I misunderstanding here? Here are the signals from samples 20000 to 30000. How should I reproduce a signal reminiscent of my original recording if I have the instantaneous frequency?
The f[i] * i together determine the phase and frequency at every i so sine wave is only rendered correctly if there is no speed change, so the algorithm must be changed to allow for continuous time i and any change in frequency must not cause a phase jump.
So try a phase accumulator approach, where phase for each i is incremented as required by the frequency.