home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / BSDSoundLib 1.0.3 / BSDSoundLib.doc < prev    next >
Encoding:
Text File  |  1997-08-03  |  3.0 KB  |  103 lines  |  [TEXT/CWIE]

  1. BSDSoundLib v1.0.3
  2. BuggySoft™ Development
  3. By Scott Dunbar.
  4. © 1997.
  5.  
  6. email    : buggysft@aimnet.com
  7. web        : http://www.aimnet.com/~buggysft/
  8. ftp        : ftp://ftp.aimnet.com/pub/users/buggysft/
  9.  
  10. BSDSoundLib is a CodeWarrior 11 library that I made for my own use in a game of ours called 
  11. Torture Chamber. You can use this lib free of charge, but please send me an email or 
  12. something and say hi (it's only fair :).
  13.  
  14. With this, you can easily have async sound play-back on multiple channels (RAM permitting) 
  15. and do some cool stereo panning as well as have background music. In my opinion, this is the
  16. easiest set of sound routines to use ever.
  17.  
  18. Call this routines like this:
  19.  
  20. // to play one sound normally
  21. {
  22.         // get your sound to play
  23.     Handle    sndHandle = GetResource('snd ', 128);    
  24.  
  25.         // Initialize 5 sound channels and other stuff
  26.     InitSoundUtils(5);
  27.         
  28.         // grab a free channel
  29.     short chanNum = FindFreeChannel();
  30.     
  31.         // check to see if a channel was found (kNoFreeChannels (-1) is returned if not)
  32.         // then play the sound on that channel
  33.     if (chanNum != kNoFreeChannels) PlaySoundChan(chanNum, sndHandle);
  34.     
  35.         // do something until the sound is finished playing
  36.     while (sndChanActive[chanNum]) {
  37.         ...something...
  38.     }
  39.     
  40.         // Silence the channel if needed (not needed if the sound is already finished)
  41.     SilenceChannel(chanNum);
  42.     
  43.         // Dispose of everything (except your aquired sound handles when you're done
  44.     DisposeSoundUtils();
  45. }    
  46.  
  47. // to change the volume of a channel
  48. {
  49. /*
  50.     setup a channel first
  51. */
  52.     SetChanVol(chanNum, kMaxLeft);    // sets the left volume full and the right to 0
  53.     SetChanVol(chanNum, kMaxRight);    // sets the right volume full and the left to 0
  54.     SetChanVol(chanNum, kBalanced);    // balances the volume on a given channel
  55.     
  56.     BalanceSndChannels();            // balances volume on all channels
  57.     
  58. /*
  59.     you can use any number from -128 to 128 for the volume.
  60. */
  61. }
  62.  
  63. // to play a sound and keep it looping (for cool background music or something)
  64. {
  65.         // load your sound, lock it and detach it
  66.     Handle    sndHandle = GetResource('snd ', 128);    
  67.     HLock(sndHandle);
  68.     DetachResource(sndHandle);
  69.     
  70.         // Initialize the looping sound channel
  71.     InitLoopingSounds();
  72.     
  73.         // Start the sound on its jolly little looping way
  74.     PlayLoopingSound(sndHandle);
  75.     
  76.         // Silence the channel if needed
  77.     SilenceLoopingChannel();
  78.     
  79.         // Dispose of the sound channel when you're done
  80.     DisposeLoopingSounds();
  81.     
  82.         // Unlock and dispose of your sound
  83.     HUnlock(sndHandle);
  84.     DisposeHandle(sndHandle);
  85. }    
  86.  
  87.  
  88. Notes
  89.     Check out the header, "BSDSoundLib.h," for more info on them. The looping sound routines 
  90.     seem buggy, but they work (although its crashed for me a few times). Whatever you do, 
  91.     never try to play a sound in a busy channel! This library is only ppc for now. I haven't
  92.     had a chance to add in the 68k support code. I'll do it soon (or you can do it and send
  93.     me a copy).
  94.  
  95. For working examples of the library in use, check in the 'examples' folder 
  96. contained in this archive.
  97.  
  98. E-mail me for updates at:
  99.     buggysft@aimnet.com
  100.  
  101.  
  102. Thanks!
  103.     - Scott Dunbar