@Oliviastarstuff If it helps, I've solved that exact problem before by treating the input as a radial angle (-pi to pi) instead of a linear input (time). Once the input is essentially a closed-loop circle, it becomes pretty easy to interpolate properly between two points.
@Oliviastarstuff That's okay, it's wrong anyway. 🤦♂️ 😆 Sorry, I was thinking of a different, but similar problem.
Your issue can be solved by tracking the time variable separately.
Instead of multiplying by the frequency by the time value when you feed them into the sin wave, store your own separate timer value and when you increment it each frame, multiply that increment by the frequency.
That way it will retain a consistent state between update frames, regardless of any jumps in frequency/timescale.