<div dir="ltr">Just to reinforce Kas&#39;s point:<div><br></div><div>Recently, I had an experience using headphones with ChucK on my mac where I had an improperly set filter value, and it blew up in my ears. Before trying the code, I had set the volume on my mac to the lowest setting, but as Kas and others have explained, when you multiply 0.01 by 10^30, you get 10^28 (figures approximate...), so it&#39;s basically giving you the loudest possible sound on your computer, even if you&#39;ve set your volume as low as possible.</div><div><br></div><div>My ears seem to be fine, but I was pretty rattled by the experience. Talking to a friend about it, he mentioned that he knew someone who really destroyed her hearing in one ear playing with filters in MAX.</div><div><br></div><div>From now on, I&#39;m going to be using this code, and inserting one of these before my DAC whenever I use chuck:</div><div><br></div><div><p style="margin:0px;font-size:13px;font-family:Monaco"><span style="color:rgb(4,51,255)">class</span> HardLimit <span style="color:rgb(4,51,255)">extends</span> <span style="color:rgb(180,54,240)">Chugen</span> {</p>
<p style="margin:0px;font-size:13px;font-family:Monaco">    <span style="color:rgb(222,146,16)">2</span> =&gt; <span style="color:rgb(4,51,255)">float</span> limit;</p>
<p style="margin:0px;font-size:13px;font-family:Monaco">    <span style="color:rgb(4,51,255)">fun</span> <span style="color:rgb(4,51,255)">float </span>tick(<span style="color:rgb(4,51,255)">float</span> in) {</p>
<p style="margin:0px;font-size:13px;font-family:Monaco">        <span style="color:rgb(4,51,255)">return</span> <span style="color:rgb(0,165,0)">Math</span>.min(<span style="color:rgb(0,165,0)">Math</span>.max(in, -limit), limit);</p>
<p style="margin:0px;font-size:13px;font-family:Monaco">    }</p>
<p style="margin:0px;font-size:13px;font-family:Monaco">    <span style="color:rgb(4,51,255)">fun</span> <span style="color:rgb(4,51,255)">float</span> setLimit(<span style="color:rgb(4,51,255)">float</span> limit) {</p>
<p style="margin:0px;font-size:13px;font-family:Monaco">        limit =&gt; <span style="color:rgb(4,51,255)">this</span>.limit;</p>
<p style="margin:0px;font-size:13px;font-family:Monaco">    }</p>
<p style="margin:0px;font-size:13px;font-family:Monaco">}</p><p style="margin:0px;font-size:13px;font-family:Monaco"><br></p><p style="margin:0px;font-size:13px;font-family:Monaco"><span style="font-family:arial,sans-serif;font-size:small">I think this is a serious issue for mac users and that it should be addressed in the next build. My suggestion is to have a parameter of the dac ugen called dac.limit, which is automatically set to 2 or 3 or so, and which acts as a hard limit applied to the audio data going into the dac. A user could set their own limit or set it to -1 or something to indicate no limit. But I think the default should be something that will not destroy anyone&#39;s hearing. :-)</span><br></p><p style="margin:0px;font-size:13px;font-family:Monaco"><span style="font-family:arial,sans-serif;font-size:small"><br></span></p><p style="margin:0px;font-size:13px;font-family:Monaco"><span style="font-family:arial,sans-serif;font-size:small">Marc</span></p><p style="margin:0px;font-size:13px;font-family:Monaco"><br></p><p style="margin:0px;font-size:13px;font-family:Monaco"><span style="font-family:arial,sans-serif;font-size:small"><br></span></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 26, 2015 at 5:33 AM, Kassen <span dir="ltr">&lt;<a href="mailto:signal.automatique@gmail.com" target="_blank">signal.automatique@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">Hey, Robert!<br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On 26 February 2015 at 06:50, Robert Poor <span dir="ltr">&lt;<a href="mailto:rdpoor@gmail.com" target="_blank">rdpoor@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"><div>On Wed, Feb 25, 2015 at 11:18 AM, Kassen <span dir="ltr">&lt;<a href="mailto:signal.automatique@gmail.com" target="_blank">signal.automatique@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote></div><div><br></div>&gt; [on windows] turning down the volume to a comfortable level won&#39;t help against that explosion<div><br></div><div>Are you saying there&#39;s no way to turn down the *output* of the DACs?</div><div><br></div></div></blockquote><div><br></div></div></div><div>Let me first clarify; where you wrote &quot;[on Windows]&quot; I meant in systems using a floating point internal sound router. In our case that is really only OSX.</div><div><br></div><div>Clearly you can turn the dac up or down using dac.gain( float).</div><div><br></div><div>What I meant is that we have some sort of issue in our code that sends a signal with a huge amplitude, let&#39;s assume some signal with 10 digits worth of amplitude, it is hard to turn that down in a meaningful way. If we set the dac&#39;s gain to 0.1 then there will still be 9 digits worth of amplitude left; still orders of magnitude louder than what our hardware can deal with. </div><div><br></div><div>Under normal conditions we would not make such a mistake, but runaway feedback, such as we might encounter in a unstable filter, will rapidly approach the max of what can be expressed in double-precission floats.</div><div><br></div><div>There ways to deal with that. We could use a limiter or clipper. You can also use a external hardware gain and leave your system volume at 100%.</div><div><br></div><div>I hope that clarifies how I believe it all works. If you are on Windows or Linux I don&#39;t believe this will matter to you, sorry if I was unclear there.</div><div><br></div><div>Yours,</div><div>Kas.</div></div></div></div>
<br>_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Marc Evans<div>PhD Student in Music Composition at UCSB<br>Stanford BA &#39;10, Music; MA &#39;11, Music, Science and Technology<br><a href="http://www.marcevansmusic.com/" target="_blank">www.marcevansmusic.com</a><br><br>&quot;We are here on Earth to do good to others. What the others are here for, I don&#39;t know.&quot;<br>    --W. H. Auden</div></div></div>
</div>