<div dir="ltr"><div><div><div>Hello Forrest,<br><br></div>You may want to check your frequency maths -- I added &lt;&lt;&lt;r.gain(), r.freq()&gt;&gt;&gt;; to the loop and the odd sounds at the beginning are frequencies way above human hearing range.<br></div><div><br></div><div>0.000000 300.000000<br>0.005000 3000000.000000<br>0.010000 1500000.000000<br>0.015000 1000000.000000<br>0.020000 750000.000000<br>0.025000 600000.000000<br>0.030000 500000.000000<br>0.035000 428571.428571<br>0.040000 375000.000000<br>0.045000 333333.333333<br>0.050000 300000.000000<br>...<br><br></div>Cheers,<br><br></div>   michael<br><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 19, 2018 at 11:22 PM, Forrest Cahoon <span dir="ltr">&lt;<a href="mailto:forrest.cahoon@gmail.com" target="_blank">forrest.cahoon@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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_<wbr>STEPS))) =&gt; r.freq;<br>    }<br>    1::ms =&gt; now;<br>}<div><br></div></div>
<br>______________________________<wbr>_________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.<wbr>princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank">https://lists.cs.princeton.<wbr>edu/mailman/listinfo/chuck-<wbr>users</a><br>
<br></blockquote></div><br></div>