home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22162 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  2.6 KB

  1. 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
  2. From: REEKES@applelink.apple.com (Jim Reekes)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Problems with sound (again)
  5. Message-ID: <REEKES-250193130203@90.10.20.67>
  6. Date: 25 Jan 93 21:03:30 GMT
  7. References: <1993Jan24.192848.159533@zeus.calpoly.edu>
  8. Sender: news@gallant.apple.com
  9. Followup-To: comp.sys.mac.programmer
  10. Distribution: na
  11. Organization: Apple Computer, Inc.
  12. Lines: 52
  13.  
  14. In article <1993Jan24.192848.159533@zeus.calpoly.edu>,
  15. tjohnson@joule.elee.calpoly.edu (Todd Johnson) wrote:
  16. > Newsgroups: comp.sys.mac.programmer
  17. > Subject: Another sound problem
  18. > Summary: System 6 barfs
  19. > Followup-To: 
  20. > Distribution: na
  21. > Organization: California Polytechnic State University, San Luis Obispo
  22. > Keywords: snd, System 6
  23. > I use the following function to play sounds:
  24. > void play_sound(short res_id)
  25. > {
  26. >   SndChannelPtr  aChannel;
  27. >   OSErr          err;
  28. >   Handle         itsSound;
  29. >   itsSound = GetResource('snd ', res_id);
  30. >   if (itsSound != NULL)
  31. >   {
  32. >     aChannel = NULL;
  33. >     err = SndNewChannel(&aChannel, sampledSynth, initMono, NULL);
  34. >     if (err == noErr)
  35. >       SndPlay(aChannel, itsSound, FALSE);
  36. >     SndDisposeChannel(aChannel, FALSE);
  37. >     ReleaseResource(itsSound);
  38. >   }
  39. > }
  40. >   This works fine as long as I run it under System 7. However, when I
  41. > compile and run under System 6, it crashes the machine. Ideally, I
  42. > would like to have a function to play sounds that works under both
  43. > operating systems. What am I doing wrong?
  44.  
  45. * the 'snd ' resource may be getting purged after calling SndNewChannel
  46. * don't call SndDisposeChannel unless SndNewChannel returned noErr
  47. * don't call SndPlay with a 'snd ' resource that specifies a 'snth' ID
  48.   if you've already allocated the channel for a snth. Format 2 'snd ' is
  49.   assumed to be sampledSynth. Most format 1 'snd ' have snth information
  50.   in them as well. Try passing 0 instead of sampledSynth to SndNewChannel.
  51. * since you're playing the 'snd ' sychronously, just do this one line:
  52.  
  53. err = SndPlay(nil, GetResource('snd ', resID), false);
  54.  
  55. -----------------------------------------------------------------------
  56. Jim Reekes, Polterzeitgeist  |     Macintosh Toolbox Engineering
  57.                              |          Sound Manager Expert
  58. Apple Computer, Inc.         | "All opinions expressed are mine, and do
  59. 20525 Mariani Ave. MS: 81-KS |   not necessarily represent those of my
  60. Cupertino, CA 95014          |       employer, Apple Computer Inc."
  61.