home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pageworks.com!world!eff!sol.ctr.columbia.edu!emory!swrinde!zaphod.mps.ohio-state.edu!darwin.sura.net!udel!intercon!psinntp!uu0570!Daniel_R._Sandler
- Message-ID: <1992Nov16.162355.40024@uu0570.foggybottom.com>
- Newsgroups: comp.sys.mac.programmer
- Distribution: world
- From: Daniel_R._Sandler@uu0570.foggybottom.com
- Organization: Foggy Bottom / Washington, D.C.
- Date: Mon, 16 Nov 1992 16:23:55 EST
- Subject: Fwd: Re: sndPlay while animat
- Lines: 87
-
- In article <BxruHF.F11.1@cs.cmu.edu> mak+@cs.cmu.edu (Matthew Alan Kane)
- writes:
- >Situation:
- >I have animation running during vbl
- >and am playing snd resources with sndPlay.
- >
- >Problem:
- >How do I keep my animation going while the sound is playing?
- >
- >mak@cs.cmu.edu
-
- Hi..
-
- I assume when you call SndPlay, the computer then freezes until it's
- done playing the sound? Or even if you're playing it asynchronously and
- that's not working well, the following should help.
-
- I wrote some simple code in Think C for a game I'm working on to play
- sounds in the background. For me the sounds seem totally independent of
- the animation; that is, the animation doesn't get in the way of the
- sound
- and vice-versa. It works.
-
- Here's the code:
-
- First, set up a sound channel.
-
- void ThisWorks(void)
- {
- SndChannelPtr myChannel;
- OSErr myErr;
- SndCommand mySndCommand;
- Handle mySoundEffect;
-
- myErr = SndNewChannel(&myChannel, sampledSynth, initMono, nil);
-
- mySoundEffect = GetResource('snd ', SOUND_RESOURCE_ID);
-
- mySndCommand.param1 = 0;
- mySndCommand.param2 = 0;
- mySndCommand.cmd = flushCmd;
-
- myErr = SndDoImmediate(myChannel, &mySndCommand);
- myErr = SndPlay(myChannel, mySoundEffect, true);
- }
-
- Of course, you need to include <sound.h> at the beginning of your program.
-
- I'm not certain the "flushCmd" deal is necessary.. (I wrote this awhile
- ago,
- in Pascal at first, so if you're using Pascal and have a problem
- converting
- it, buzz me.) I think that just flushes the channel in case any other
- sounds
- are playing on it.
-
- Actually, it's useful to set up multiple channels (on sound-capable Macs
- you
- have 4), because then you can use one channel for a continuous
- soundtrack,
- and another channel for sound effects, etc. (Of course this method
- might
- cause problems if you're competing with other programs for the same channel,
- etc.)
-
- Hope that helps!
-
- M. Scott Smith
- (mssmith@afterlife.ncsc.mil || umsmith@mcs.drexel.edu)
-
-
- ------ Internet Message Header Follows ------
- Path:
- uupsi!psinntp!rpi!usc!sdd.hp.com!wupost!darwin.sura.net!haven.umd.edu!mimsy!afterlife!mssmith
- From: mssmith@afterlife.ncsc.mil (M. Scott Smith)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: sndPlay while animating
- Keywords: Mac, sndPlay, animation
- Message-ID: <1992Nov15.235830.17180@afterlife.ncsc.mil>
- Date: 15 Nov 92 23:58:30 GMT
- References: <BxruHF.F11.1@cs.cmu.edu>
- Organization: The Great Beyond
- Lines: 61
-
-
- Foggy Bottom - your FirstClass Mac connection in Washington, DC
-
-