<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hey folks, I'm puzzled why these two shreds don't make the same sound. I created a simple bit crusher using an integer as an index and then using time as an index; I thought these were equivalent but they aren't. I wonder if this is because the integer increments at a different rate than the sampling rate? Any guidance on this gratefully received! Thanks,<div><br></div><div>Charlie </div><div><br></div><div>First shred:</div><div>//---------------------------------------------</div><div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(162,0,236)">SinOsc<span style="color:rgb(0,0,0)"> s => </span><span style="color:rgb(0,0,255)">dac</span><span style="color:rgb(0,0,0)">;</span></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;min-height:17px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span style="color:rgb(212,128,16)">110</span> => s.freq;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;min-height:17px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span style="color:rgb(212,128,16)">0</span> => <span style="color:rgb(0,0,255)">int</span> i;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span style="color:rgb(212,128,16)">250</span> => <span style="color:rgb(0,0,255)">int</span> iMax;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span style="color:rgb(212,128,16)">0</span> => <span style="color:rgb(0,0,255)">int</span> jCount;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;min-height:17px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,255)">while<span style="color:rgb(0,0,0)"> (</span>true<span style="color:rgb(0,0,0)">) {</span></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>i++;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0);min-height:17px"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(96,144,16)">//<span class="gmail-Apple-tab-span" style="white-space:pre">        </span>if (i%130 == 0 || i%201 ==0 || i% 737 == 0) 0 =>s.gain;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span style="color:rgb(0,0,255)"> if</span><span style="color:rgb(96,144,16)"> </span>(i%iMax<span style="color:rgb(96,144,16)"> </span>><span style="color:rgb(96,144,16)"> </span>jCount<span style="color:rgb(96,144,16)"> </span>)<span style="color:rgb(96,144,16)"> </span><span style="color:rgb(212,128,16)">0</span>.<span style="color:rgb(212,128,16)">0</span><span style="color:rgb(96,144,16)"> </span>=>s.gain;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>jCount++;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span><span style="color:rgb(0,0,255)">if</span> (jCount > iMax) <span style="color:rgb(212,128,16)">0</span> => jCount;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(96,144,16)">//<span class="gmail-Apple-tab-span" style="white-space:pre">        </span>1::samp => now;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"> .<span style="color:rgb(212,128,16)">1</span>::<span style="color:rgb(0,0,255)">ms</span> => <span style="color:rgb(0,0,255)">now</span>;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span><span style="color:rgb(212,128,16)">1</span> => s.gain;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;min-height:17px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)">}</p><p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><br></p><div>//---------------------------------------------</div><div><br></div><div>second shred:</div><div><br></div><div><div>//---------------------------------------------</div></div><div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(162,0,236)">SinOsc<span style="color:rgb(0,0,0)"> s => </span><span style="color:rgb(0,0,255)">dac</span><span style="color:rgb(0,0,0)">;</span></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;min-height:17px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span style="color:rgb(212,128,16)">110</span> => s.freq;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0);min-height:17px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span style="color:rgb(212,128,16)">0</span>::<span style="color:rgb(0,0,255)">samp</span> => <span style="color:rgb(0,0,255)">dur</span> jMin;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span style="color:rgb(212,128,16)">250</span>::<span style="color:rgb(0,0,255)">samp</span> => <span style="color:rgb(0,0,255)">dur</span> iMax;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span style="color:rgb(212,128,16)">0</span>::<span style="color:rgb(0,0,255)">samp</span> => <span style="color:rgb(0,0,255)">dur</span> jCount;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span style="color:rgb(212,128,16)">1</span>::<span style="color:rgb(0,0,255)">samp</span> => <span style="color:rgb(0,0,255)">dur</span> jDelta;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;min-height:17px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,255)">while<span style="color:rgb(0,0,0)"> (</span>true<span style="color:rgb(0,0,0)">) {</span></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(96,144,16);min-height:17px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span><span style="color:rgb(0,0,255)">if</span> (<span style="color:rgb(0,0,255)">now</span>%iMax > jCount ) <span style="color:rgb(212,128,16)">0</span>.<span style="color:rgb(212,128,16)">0</span> =>s.gain;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>jCount+jDelta => jCount;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span><span style="color:rgb(0,0,255)">if</span> (jCount > iMax) jMin => jCount;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>.<span style="color:rgb(212,128,16)">1</span>::<span style="color:rgb(0,0,255)">ms</span> => <span style="color:rgb(0,0,255)">now</span>;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span><span style="color:rgb(212,128,16)">1</span> => s.gain;</p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;min-height:17px"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)">}</p></div><div><br></div><div><br></div><div><div>//---------------------------------------------</div></div><div><br></div><p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Monaco;color:rgb(0,0,0)"><br></p></div></div></div></div></div></div></div>