Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!usc!apple!Apple.COM!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Synchronous sounds using the Sound Manager Message-ID: <8548@goofy.Apple.COM> Date: 5 Jun 90 19:02:43 GMT Sender: usenet@Apple.COM Organization: Future Stuff, Apple Computer, Inc. Lines: 40 References:<1990Jun4.020601.9644@msuinfo.cl.msu.edu> <30976@ut-emx.UUCP> In article <30976@ut-emx.UUCP> wras@walt.cc.utexas.edu (Steve Mariotti) writes: > err = SndNewChannel(myChanPtr, sampledSynth, initMono, NULL); > if (!err) { > err = SndPlay(myChanPtr, soundHandle1, FALSE); > err = SndPlay(myChanPtr, soundHandle2, FALSE); > } First, to play a sound while your programs continue, you need to pass TRUE for the last parameter. This specifies asynchronous playing, which is what you want. Also, you can't (in general) play 2 snd resources with the same channel. When you play a resource, the synthesizer required by the resource is linked to the channel. If you link a syntehsizer more than once, you will (at best) not get any sound, and will probably crash. For this reason, it is best to dispose of a channel after the sound is finished playing. To do this pass a call back routine when you create the channel, and send a callBack command after the SndPlay. For the same reason, you should pass 0 instead of sampledSynth when creating the channel, in case the resource you play wants to use a different synthesizer. If you know the structure of the resources you are going to play (ie, they have no synthesizer information) then you can play several sounds on the same channel. Or you can parse the sound resource to extract the actual samples and play them. All this information comes from the revised Sound Manager documentation, which I think is available on Apple.COM (in /pub/dts/mac/docs). I've also got sample MPW Pascal code which implements an asynchronous SndPlay call. Larry Rosenstein, Apple Computer, Inc. Object Specialist Internet: lsr@Apple.com UUCP: {nsc, sun}!apple!lsr AppleLink: Rosenstein1