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

Morgan Packard morgan at morganpackard.com
Thu Feb 24 13:04:32 PST 2011


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

-- 
================================
Web:
http://www.morganpackard.com

Music/Art:
Latest album: Moment Again
Elsewhere<http://www.anticipaterecordings.com/releases/ANT_011/index.php>
iOS app Thicket
<http://itunes.apple.com/us/app/thicket/id364824621?mt=8>available on
iTunes store
.
================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ccrma-mail.stanford.edu/pipermail/stk/attachments/20110224/251830ef/attachment.html 


More information about the Stk mailing list