[Stk] could my badly-written multithreaded code be related to ADSR's value_ and releaseRate_ having NaN as a value?

Tristan Matthews le.businessman at gmail.com
Fri Feb 25 11:24:06 PST 2011


2011/2/25 Stephen Sinclair <sinclair at music.mcgill.ca>

> On Thu, Feb 24, 2011 at 4:04 PM, Morgan Packard
> <morgan at morganpackard.com> wrote:
> > Hello,
> > I'm currently calling ADSR::keyOn from my UI thread, and calling
> > ADSR::tick() from an IO callback thread.
> > This is bad, right? This class is not thread-safe, and these methods both
> > need to be called from the same thread, correct?
> > My application has a very occasional, impossible to reproduce bug which
> > results in all audio output completely stopping. I just managed to see
> the
> > bug with the debugger hooked up, and traced it back to NaN's originating
> > from ADSR. My guess is that ADSR was thrown in to this faulty state by a
> > collision between my two threads. Anyone have any other ideas of what it
> > could be, or does my hypothesis sound like a good one?
> > Is there any preferred way to trigger an ADSR from an external thread?
> Seems
> > to me that a message queue approach may be the easiest, and won't result
> in
> > any blocking of the audio thread.
> > thanks,
> > -Morgan
>
> In general I'd recommend keeping your STK code in one place, and using
> a non-blocking message queue for communication.
>

FYI, STK provides a Messager class that might help in this case:
https://ccrma.stanford.edu/software/stk/classstk_1_1Messager.html

-t

-- 
Tristan Matthews
email: tristan at sat.qc.ca
web: http://tristanswork.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ccrma-mail.stanford.edu/pipermail/stk/attachments/20110225/d9d05c01/attachment.html 


More information about the Stk mailing list