[comp.sys.mac.programmer] Mac II sound chip

dhare%integral@Sun.COM (Dwight Hare) (03/29/88)

I am interested in talking with anyone who is knowledgeable about or
interested in programming the Mac II sound chip.  I have found the
IM volume V description of the new interface to the sound chip to be
vague and my programs don't seem to work well.

My current attempt is to play digitized sound.  If I send a single
buffer of sound, it works fine.  If I send the sound in chunks, it
works for awhile then hangs.

Here's what I'm doing:

I call SndNewChannel with sampledSynth, initMono, and a callback routine.

I set up a buffer for the digitized sound (using the SoundHeader struct
found in MPW C Sound.h).  This buffer sets the length, a pointer to the
sound, the sample rate (22K), and a few other parameters.

I set up a command of type bufferCmd and a pointer to the buffer and I
do a SndDoCommand.

In order to know when the sound has finished, I do a SndDoCommand of a
callBackCmd.  The callback routine (defined in the SndNewChannel) just
sets a bit in the userInfo field of the channel which I can test in
my main program.

After the sound has finished (after the bit is set by the callback routine),
I reset the buffer to point to the next sound and then do the bufferCmd
again.

If I do the bufferCmds in a loop, it usually plays along for awhile then
hangs (my callback routine is not called and no sound comes out).  If I
time out the bufferCmd in my main program and exit, I get a bad memory
reference somewhere in ROM.

I'm checking the error returns on all of the sound calls and I get no
error indication.  I've disassembled Soundwave since it plays sound without
problems, but it is using the old interface to the sound chip.

Any help would be much appreciated.