home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-08-03 | 3.0 KB | 103 lines | [TEXT/CWIE] |
- BSDSoundLib v1.0.3
- BuggySoft™ Development
- By Scott Dunbar.
- © 1997.
-
- email : buggysft@aimnet.com
- web : http://www.aimnet.com/~buggysft/
- ftp : ftp://ftp.aimnet.com/pub/users/buggysft/
-
- BSDSoundLib is a CodeWarrior 11 library that I made for my own use in a game of ours called
- Torture Chamber. You can use this lib free of charge, but please send me an email or
- something and say hi (it's only fair :).
-
- With this, you can easily have async sound play-back on multiple channels (RAM permitting)
- and do some cool stereo panning as well as have background music. In my opinion, this is the
- easiest set of sound routines to use ever.
-
- Call this routines like this:
-
- // to play one sound normally
- {
- // get your sound to play
- Handle sndHandle = GetResource('snd ', 128);
-
- // Initialize 5 sound channels and other stuff
- InitSoundUtils(5);
-
- // grab a free channel
- short chanNum = FindFreeChannel();
-
- // check to see if a channel was found (kNoFreeChannels (-1) is returned if not)
- // then play the sound on that channel
- if (chanNum != kNoFreeChannels) PlaySoundChan(chanNum, sndHandle);
-
- // do something until the sound is finished playing
- while (sndChanActive[chanNum]) {
- ...something...
- }
-
- // Silence the channel if needed (not needed if the sound is already finished)
- SilenceChannel(chanNum);
-
- // Dispose of everything (except your aquired sound handles when you're done
- DisposeSoundUtils();
- }
-
- // to change the volume of a channel
- {
- /*
- setup a channel first
- */
- SetChanVol(chanNum, kMaxLeft); // sets the left volume full and the right to 0
- SetChanVol(chanNum, kMaxRight); // sets the right volume full and the left to 0
- SetChanVol(chanNum, kBalanced); // balances the volume on a given channel
-
- BalanceSndChannels(); // balances volume on all channels
-
- /*
- you can use any number from -128 to 128 for the volume.
- */
- }
-
- // to play a sound and keep it looping (for cool background music or something)
- {
- // load your sound, lock it and detach it
- Handle sndHandle = GetResource('snd ', 128);
- HLock(sndHandle);
- DetachResource(sndHandle);
-
- // Initialize the looping sound channel
- InitLoopingSounds();
-
- // Start the sound on its jolly little looping way
- PlayLoopingSound(sndHandle);
-
- // Silence the channel if needed
- SilenceLoopingChannel();
-
- // Dispose of the sound channel when you're done
- DisposeLoopingSounds();
-
- // Unlock and dispose of your sound
- HUnlock(sndHandle);
- DisposeHandle(sndHandle);
- }
-
-
- Notes
- Check out the header, "BSDSoundLib.h," for more info on them. The looping sound routines
- seem buggy, but they work (although its crashed for me a few times). Whatever you do,
- never try to play a sound in a busy channel! This library is only ppc for now. I haven't
- had a chance to add in the 68k support code. I'll do it soon (or you can do it and send
- me a copy).
-
- For working examples of the library in use, check in the 'examples' folder
- contained in this archive.
-
- E-mail me for updates at:
- buggysft@aimnet.com
-
-
- Thanks!
- - Scott Dunbar