<div dir="ltr">I&#39;m attempting to play with descending tones, but I&#39;m having artifacts at the beginning of the sound. I tried to start with a gain of 0 but this does not prevent the glitch.<div><br></div><div>I&#39;ve used various sorts of oscillators; when I use SinOsc there is just a glitch at the very beginning of the sound, but with SqrOsc and others there is what sounds sort of like LFO amplitude modulation for maybe even a second into the sound.</div><div><br></div><div>Here is my code. How do I fix this?</div><div><br></div>SqrOsc r =&gt; dac;  // also try SinOsc, TriOsc, and SawOsc<br><br>300.0 =&gt; float STARTING_FREQ;<br>10000 =&gt; int OCTAVE_STEPS;<br>for (0 =&gt; int i; i &lt; OCTAVE_STEPS ; i++) {<br>    <br>    // making an envelope by manipulating the gain<br>    if (i &lt; 100) {<br>        i * 0.005 =&gt; r.gain;<br>    } else if (i &gt; OCTAVE_STEPS - 100) {<br>        (OCTAVE_STEPS - i) * 0.005 =&gt; r.gain;<br>    } else {<br>        0.5 =&gt; r.gain;<br>    }<br>    <br>    // constantly falling frequency<br>    if (i == 0) {<br>        STARTING_FREQ =&gt; r.freq;<br>    } else {<br>        STARTING_FREQ * <br>        Math.pow(2.0, -1.0 * Math.log2((1.0*i)/(1.0*OCTAVE_STEPS))) =&gt; r.freq;<br>    }<br>    1::ms =&gt; now;<br>}<div><br></div></div>