2011/2/25 Stephen Sinclair <span dir="ltr"><<a href="mailto:sinclair@music.mcgill.ca">sinclair@music.mcgill.ca</a>></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>
<<a href="mailto:morgan@morganpackard.com">morgan@morganpackard.com</a>> wrote:<br>
> Hello,<br>
> I'm currently calling ADSR::keyOn from my UI thread, and calling<br>
> ADSR::tick() from an IO callback thread.<br>
> This is bad, right? This class is not thread-safe, and these methods both<br>
> need to be called from the same thread, correct?<br>
> My application has a very occasional, impossible to reproduce bug which<br>
> results in all audio output completely stopping. I just managed to see the<br>
> bug with the debugger hooked up, and traced it back to NaN's originating<br>
> from ADSR. My guess is that ADSR was thrown in to this faulty state by a<br>
> collision between my two threads. Anyone have any other ideas of what it<br>
> could be, or does my hypothesis sound like a good one?<br>
> Is there any preferred way to trigger an ADSR from an external thread? Seems<br>
> to me that a message queue approach may be the easiest, and won't result in<br>
> any blocking of the audio thread.<br>
> thanks,<br>
> -Morgan<br>
<br>
</div>In general I'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>