[comp.sys.mac.programmer] Playing sound files from Think C

mcneely@PEDEV.Columbia.NCR.COM (Alan McNeely) (07/11/90)

I've never had any occasion to work with sound on a Macintosh before.
A friend has a MacRecorder that creates sound files that can be used
in things like Hypercard stacks.  

In this format,  can they be used by a Think C program?  Or do they
need to be converted to some other format?  A little sample code would
be appreciated,  if applicable.

Thanks,

Alan McNeely
mcneely@pedev.columbia.ncr.com

sr0o+@andrew.cmu.edu (Steven Ritter) (07/11/90)

SoundEdit (the software that goes with MacRecorder) will let you save
the sound as an 'snd ' resource in your resource file.  (In the save
dialog, select your resource file and choose "resource" as the format). 
To play the sound from your program, just read in the resource and call
SndPlay:

MakeSound(sndName)

int	sndName;
{
	Handle	soundHandle;
	if ((soundHandle = GetResource('snd ',sndName)) != 0L)
	   SndPlay(NIL_SOUND_CHANNEL, soundHandle, FALSE);
}

sndName is the resource ID; NIL_SOUND_CHANNEL is 0L (to play through the
standard Mac sound channel) and the third argument is the value for
"synchronous," which indicates whether other actions can happen during
the playing of the sound.

Hope this helps.

Steve