[comp.sys.mac.programmer] Asynchronous sound help?

chopp@math.berkeley.edu (08/14/90)

I would like to play a sound asyncronously.  I have Inside Mac V in my lap
and have written the following code using TC 4.0.  Two things are wrong.
First, control is not returned to the program immediately (i.e. not played
asynchronously).  Second, the SndDisposeChannel call causes a bomb.
Here's the code:

#include <SoundMgr.h>

void CSoundPane::DoClick(Point hitPt, short modifierKeys, long when)

{
	Handle	theSound;
	SndChannelPtr	chan;
	
	theSound = GetResource('snd ', 2214);
	chan = NULL;
	SndNewChannel(&chan, sampledSynth, initSRate22k, NULL);
	SndPlay(chan, theSound, TRUE);

	/* Drawing stuff */

	SndDisposeChannel(chan, FALSE);
	ReleaseResource(theSound);
}

Thanks in advance,

Dave Chopp
chopp@math.berkeley.edu

cr_kempke@eisvxe.moundst.mn.org (Travelling SMU GURU) (08/16/90)

In article <1990Aug14.061951.25766@agate.berkeley.edu>, chopp@math.berkeley.edu writes:
> I would like to play a sound asyncronously.  I have Inside Mac V in my lap
						      ^^^^^^^^^^^^

	Here's problem #1:  IMV lies.   Get the Sound Manager document
from sumex-aim.stanford.edu (maybe) or apple.com.   It contains the chapter
re-written to be correct.

> and have written the following code using TC 4.0.  Two things are wrong.
> First, control is not returned to the program immediately (i.e. not played
> asynchronously).  Second, the SndDisposeChannel call causes a bomb.
> Here's the code:

> 
> #include <SoundMgr.h>
> 
> void CSoundPane::DoClick(Point hitPt, short modifierKeys, long when)
> 
> {
> 	Handle	theSound;
> 	SndChannelPtr	chan;
> 	
> 	theSound = GetResource('snd ', 2214);
> 	chan = NULL;
> 	SndNewChannel(&chan, sampledSynth, initSRate22k, NULL);
			     ^^^^^^^^^^^^
	Pass Zero for the synthesizer:  Your 'snd ' resource probably
already specifies the sampledsynth, and when the second one gets installed
things go haywire.  This is the cause of your problems.  

        [stuff deleted]
		
> Thanks in advance,
> 
> Dave Chopp
> chopp@math.berkeley.edu


	No problem, I've been just recently been playing with this
myself.   

	Here's a question for the rest of you:  The Sound Manager document
lists a whole pile of limitations of the "current sound manager", but also
claims that it's from system version 6.0.2.  Have any of those problems been
fixed?

	--Chris
(kempkec@mist.cs.orst.edu, despite what my header might say)

Usual disclaimer applies, especially since my employer isn't who my mail header
says it is...