 <p>If your frequency is not exactly an integer value, then this line:</p> <pre><code>phase = phase - (2 * M_PI * freq); </code></pre> <p>will adjust and rotate the phase by an amount not equal to 2pi, thus producing a discontinuity.</p>