Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!ukc!mucs!liv-cs!phil From: phil@mva.cs.liv.ac.uk Newsgroups: comp.sys.mac.programmer Subject: Re: Playing sounds async: help Message-ID: <8418@mva.cs.liv.ac.uk> Date: 30 Jun 89 11:27:53 GMT References: <7975@bsu-cs.bsu.edu> Organization: Computer Science CSMVAX, Liverpool University Lines: 42 In article <7975@bsu-cs.bsu.edu>, mithomas@bsu-cs.bsu.edu (Michael Thomas Niehaus) writes: > Help! I am trying to get async sounds to work using the sound manager, but > I have a couple of questions: > > 1. Why am I not supposed to leave an open sound channel for a period of > time? > 2. Right now, I am allocating a new channel, then doing the SndPlay. I > can see that the processing right after that is getting done. But it > finishes before the sound. So my SndDisposeChannel (or however it is > spelled) will just sit there and wait until the sound is finished. (Yes, > I want it to do that -- I don't want to chop the sound off right in the > middle of playing.) I could check in the event loop to see if the > sound is done, and if it is then dispose the channel. But how can I > find out if it is finished? > > Mac programming is so much fun (seriously)... > > -Michael > > -- > Michael Niehaus UUCP: !{iuvax,pur-ee}!bsu-cs!mithomas > Apple Student Rep ARPA: mithomas@bsu-cs.bsu.edu Well, you can use the CallBackCmd to let you know when a sound has finished. What I have done is to have a global Boolean. The CallBack calls a procedure which sets up access to global variables (a callback is done at interrupt time so the A5 world is not normally set up) sets the Boolean appropriately, and then restores A5 to whatever it was. Seems to work OK for me. I have lots of short sounds (actually individual words) which I make into sentences, and I do some animation while the words are being spoken. The soundplay code I use was posted by someone to Usenet a while ago. I added the callback bit from information in the docs that were posted to Usenet to replace the SoundManager chapter in Vol V. By the way - I'm not recommending my method, but it does seem to work, for now... Ho Hum... Phil Jimmieson, *************************************************** Computer Science Dept., * * Liverpool University, * JANET : PHIL@UK.AC.LIV.CS.MVA * PO Box 147 * ARPA : PHIL%mva.cs.liv.ac.uk@cunyvm.cuny.edu * Liverpool L69 3BX * * (UK) 051-794-3689 ***************************************************