First and most importantly...sound effects MUST be added to your GDM file. There is just no other way to do this without some serious additional coding. So, to keep things simple for now, just do it! Add your sounds to the file. There's a little thing you want to watch out for, and that's placement. You see, GDM's sample slots are listed from 0. Some trackers start their sample slots at 1 (like ScreamTracker). So, you have to take this into consideration. For example, in WOS, samples start at GDM Slot 64. However, when I use ST3 to make the S3M files I will later convert with 2GDM, I have to store samples starting at 65. Some Amiga programs store starting at 0.
So, let's say that you have five sound effects you want to add. If these five sounds are meant to be heard throughout the entire game or application, a good idea would be to add then to each music file in the same order, and in the same place in the file. So, maybe CLANG.WAV goes into slot 65, STOMP.SMP goes into slot 66, and so on. The smart planner keeps this kind of thing consistant throughout all the files.
Once you've done that, you'll want to be able to play those sounds. Playing sounds requires the use of a channel. However, since all the channels alloc- ated are being used to play music, what do you do? Well, simple! When starting the sound output:
OverRate& = StartOutput(MusicChannels, 0)simply allocate more channels! For example...
OverRate& = StartOutput(MusicChannels + 2, 0)Keep in mind that more channels means more CPU time (except GUS...again!)
Now, remember what channels you allocated for sound...it will be important when playing sound effects.
So, when your tune is playing (though music doesn't have to be playing to play SFX, the module does have to be loaded) what you would do is use the PlaySample command:
PlaySample Channel%, Sample%, Rate&, Vol%, Pan%For example:you have a sample at 45 you wish to play on channel 7, full volume, at a rate of 22000, centered. Here's how you'd do it:
PlaySample 7, 45, 22000, 64, 8Some of these are quite obvious...the most unobvious would be Pan%. This can be any number from 0-15, or &HFF for 'no change'. Any number beside 0, 8, or 15 is going to take more CPU time (except...you guessed it...a GUS card!)
Defining a different volume can be useful for echoes, like listed in BWSB-REF. However, a cool effect could also be to alter the volume AND the Panning. For example, start at a low volume at pan 0, then increase the volume as you move up to pan 8. Then as you pan to 15, lower the volume. Like this:
PlaySample 7, 45, 22000, 32, 0 PlaySample 7, 45, 22000, 36, 1 PlaySample 7, 45, 22000, 40, 2 PlaySample 7, 45, 22000, 44, 3 PlaySample 7, 45, 22000, 48, 4 PlaySample 7, 45, 22000, 52, 5 PlaySample 7, 45, 22000, 56, 6 PlaySample 7, 45, 22000, 60, 7 PlaySample 7, 45, 22000, 64, 8 PlaySample 7, 45, 22000, 60, 9 PlaySample 7, 45, 22000, 56, 10 PlaySample 7, 45, 22000, 52, 11 PlaySample 7, 45, 22000, 48, 12 PlaySample 7, 45, 22000, 44, 13 PlaySample 7, 45, 22000, 40, 14 PlaySample 7, 45, 22000, 36, 15Of course, that exact method is horribly inefficient (a smart coder would have used a loop), but you get the idea.
Okay! That just about covers all you need to know for a basic sound structure! Over the next couple of months, I will be getting into some advanced programming features of BWSB, including scopes, dynamic sample allocation, and more.© Copyright 1999 Nightwolf Productions