2011/2/25 Stephen Sinclair <span dir="ltr">&lt;<a href="mailto:sinclair@music.mcgill.ca">sinclair@music.mcgill.ca</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Thu, Feb 24, 2011 at 4:04 PM, Morgan Packard<br>
&lt;<a href="mailto:morgan@morganpackard.com">morgan@morganpackard.com</a>&gt; wrote:<br>
&gt; Hello,<br>
&gt; I&#39;m currently calling ADSR::keyOn from my UI thread, and calling<br>
&gt; ADSR::tick() from an IO callback thread.<br>
&gt; This is bad, right? This class is not thread-safe, and these methods both<br>
&gt; need to be called from the same thread, correct?<br>
&gt; My application has a very occasional, impossible to reproduce bug which<br>
&gt; results in all audio output completely stopping. I just managed to see the<br>
&gt; bug with the debugger hooked up, and traced it back to NaN&#39;s originating<br>
&gt; from ADSR. My guess is that ADSR was thrown in to this faulty state by a<br>
&gt; collision between my two threads. Anyone have any other ideas of what it<br>
&gt; could be, or does my hypothesis sound like a good one?<br>
&gt; Is there any preferred way to trigger an ADSR from an external thread? Seems<br>
&gt; to me that a message queue approach may be the easiest, and won&#39;t result in<br>
&gt; any blocking of the audio thread.<br>
&gt; thanks,<br>
&gt; -Morgan<br>
<br>
</div>In general I&#39;d recommend keeping your STK code in one place, and using<br>
a non-blocking message queue for communication.<br></blockquote><div><br>FYI, STK provides a Messager class that might help in this case:<br><a href="https://ccrma.stanford.edu/software/stk/classstk_1_1Messager.html">https://ccrma.stanford.edu/software/stk/classstk_1_1Messager.html</a><br>
<br>-t<br clear="all"></div></div><br>-- <br>Tristan Matthews<br>email: <a href="mailto:tristan@sat.qc.ca">tristan@sat.qc.ca</a><br>web: <a href="http://tristanswork.blogspot.com">http://tristanswork.blogspot.com</a><br>