home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!swrinde!zaphod.mps.ohio-state.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!olivea!apple!goofy!mumbo.apple.com!gallant.apple.com!NewsWatcher!user
- From: REEKES@applelink.apple.com (Jim Reekes)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Problems with sound (again)
- Message-ID: <REEKES-250193130203@90.10.20.67>
- Date: 25 Jan 93 21:03:30 GMT
- References: <1993Jan24.192848.159533@zeus.calpoly.edu>
- Sender: news@gallant.apple.com
- Followup-To: comp.sys.mac.programmer
- Distribution: na
- Organization: Apple Computer, Inc.
- Lines: 52
-
- In article <1993Jan24.192848.159533@zeus.calpoly.edu>,
- tjohnson@joule.elee.calpoly.edu (Todd Johnson) wrote:
- >
- > Newsgroups: comp.sys.mac.programmer
- > Subject: Another sound problem
- > Summary: System 6 barfs
- > Followup-To:
- > Distribution: na
- > Organization: California Polytechnic State University, San Luis Obispo
- > Keywords: snd, System 6
- >
- > I use the following function to play sounds:
- >
- > void play_sound(short res_id)
- > {
- > SndChannelPtr aChannel;
- > OSErr err;
- > Handle itsSound;
- >
- > itsSound = GetResource('snd ', res_id);
- > if (itsSound != NULL)
- > {
- > aChannel = NULL;
- > err = SndNewChannel(&aChannel, sampledSynth, initMono, NULL);
- > if (err == noErr)
- > SndPlay(aChannel, itsSound, FALSE);
- > SndDisposeChannel(aChannel, FALSE);
- > ReleaseResource(itsSound);
- > }
- > }
- >
- > This works fine as long as I run it under System 7. However, when I
- > compile and run under System 6, it crashes the machine. Ideally, I
- > would like to have a function to play sounds that works under both
- > operating systems. What am I doing wrong?
-
- * the 'snd ' resource may be getting purged after calling SndNewChannel
- * don't call SndDisposeChannel unless SndNewChannel returned noErr
- * don't call SndPlay with a 'snd ' resource that specifies a 'snth' ID
- if you've already allocated the channel for a snth. Format 2 'snd ' is
- assumed to be sampledSynth. Most format 1 'snd ' have snth information
- in them as well. Try passing 0 instead of sampledSynth to SndNewChannel.
- * since you're playing the 'snd ' sychronously, just do this one line:
-
- err = SndPlay(nil, GetResource('snd ', resID), false);
-
- -----------------------------------------------------------------------
- Jim Reekes, Polterzeitgeist | Macintosh Toolbox Engineering
- | Sound Manager Expert
- Apple Computer, Inc. | "All opinions expressed are mine, and do
- 20525 Mariani Ave. MS: 81-KS | not necessarily represent those of my
- Cupertino, CA 95014 | employer, Apple Computer Inc."
-