home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!mintaka.lcs.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!slchambe
- From: slchambe@athena.mit.edu (Stephen L Chamberlin)
- Newsgroups: comp.sys.mac.programmer
- Subject: help with asynchronous sounds
- Message-ID: <1992Aug14.141851.945@athena.mit.edu>
- Date: 14 Aug 92 14:18:51 GMT
- Sender: news@athena.mit.edu (News system)
- Organization: Massachusetts Institute of Technology
- Lines: 57
- Nntp-Posting-Host: e40-008-11.mit.edu
-
- I'm going crazy trying to write some code that plays sounds asynchronously
- (for sound effects in a game). After reading the sound manager chapter in
- IM 5, I wrote some code that seems to work great under system 7, but chokes
- under system 6. Could somebody tell me what I'm doing wrong, or give me a
- pointer to an example use of asynchronous sounds? I checked the soundapp at
- ftp.apple.com, but the only way it plays asynchronous sounds is by creating
- a new channel, playing the sound asynchronously, and then disposing of the
- channel. I want to create 1 channel that I keep around for the whole game that
- plays all the sound effects.
-
- When my program starts up, I create a new sound channel, which I use for
- playing all my sound effects. Each time I want to play a sound effect, I
- do SndPlay(myChan, mySound, TRUE); to play it asynchronously. This works
- fine for system 7, but when I try it under system 6, the 1st sound effect
- I try to play works, but all others afterward don't get played. No crashes
- or anything, just no more sound effects. Here's what I'm doing:
-
- SndChannelPtr myChan;
- Handle mySound, mySound2;
-
- some_routine()
- {
- myChan = (SndChannelPtr)0L;
- if (SndNewChannel(&myChan,sampledSynth,0,0L) != noErr)
- MyHandleError();
-
- mySound = GetResource('snd ',128);
- if (mySound == 0L)
- MyHandleError();
- HLock(mySound);
- mySound2 = GetResource('snd ',129);
- if (mySound2 == 0L)
- MyHandleError();
- HLock(mySound2);
-
- ...
-
- SndPlay(myChan,mySound,TRUE); /* this sound gets played asynchronously */
- SndPlay(myChan,mySound2,TRUE); /* this sound is never heard */
-
- /* any subsequent SndPlay(myChan...) calls fail to produce any sound */
-
- ...
-
- }
-
- I also tried this with "sampledSynth" replace by "0" with the same results.
- Any ideas why this doesn't work? As I said, it seems to work fine under
- system 7, but not system 6. I can't understand why. Is there some other
- way I should be playing asynchronous sounds? The sounds don't need to overlap
- each other, they just shouldn't stop program execution while they play.
-
- Any help you could give me with this problem would be greatly appreciated. It's
- driving me nuts! Thanks in advance!
-
- Steve Chamberlin
- slchambe@athena.mit.edu
-