Path: utzoo!attcan!uunet!cs.utexas.edu!usc!apple!Apple.COM!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Playing sounds async: help Message-ID: <2587@internal.Apple.COM> Date: 30 Jun 89 00:23:31 GMT References: <7975@bsu-cs.bsu.edu> Sender: usenet@Apple.COM Organization: Objects-R-Us, Apple Computer, Inc. Lines: 36 In article <7975@bsu-cs.bsu.edu> mithomas@bsu-cs.bsu.edu (Michael Thomas Niehaus) writes: > 1. Why am I not supposed to leave an open sound channel for a period of > time? I think that when you create a sound channel, you get control of the sound hardware, which prevents anyone else from making a sound. (According to the System 7.0 preliminary docs, this is supposed to be fixed.) > 2. Right now, I am allocating a new channel, then doing the SndPlay. I > sound is done, and if it is then dispose the channel. But how can I > find out if it is finished? You need to put a call back command in the channel after you play the sound, and specify a call back routine when you create the channel. Your call back routine will get called when the sound finishes. Other things to watch out for. You can't reuse the sound channel, because once you play a snd resource with it, the channel gets linked with a synthesizer. You must lock the snd handle if you are playing it asynchronously SndPlay will lock it for the duration of the call only, which will be shorter than the duration of the sound (if you are using async sound). Finally, you can look at the sample unit that I wrote, which should be on Info-Mac. (It also appeared recently on comp.sources.mac.) It was written in Pascal and shows how to do all these things. Larry Rosenstein, Apple Computer, Inc. Object Specialist Internet: lsr@Apple.com UUCP: {nsc, sun}!apple!lsr AppleLink: Rosenstein1