Step 10


There is one call needed to add randomly generated sounds to your game. These random sounds are attached to other sounds with the following call.

 bool addRandomSound(soundIDenum ID_random, soundBufferRef* sIDMain, bool f3D,                  int playsPer100Seconds); 

A good example is adding random thunder to the ambient sound of rain. Remember that in Step 8, the following code started the rain.

 soundBufferRef sIDRain;  if (Concertina.getSoundID(ID_rain,&sIDRain))     Concertina.playAmbientSound(&sIDRain,true,100); 

Then, to add a clap of thunder, occurring on average five times per 100 seconds of rain time, use the following call.

 Concertina.addRandomSound(ID_thunder,&sIDRain,false,5); 

The first parameter identifies the random sound that we want, the second the ID of the sound to attach it to, the third should be true if we want a 3-D sound, and the last is the number of times per 100 seconds that it should be played .

There is no need to call getSoundID for a random sound; once you have made this one call, the framework takes care of the buffer references for you. However you must call commitAllSettings for your random sounds to take effect (see Step 9), as this is the call that actually fires off the random sounds. If you have one or more random sounds, call commitAllSettings , even if you have no 3-D sounds.

Stopping the main sound will automatically stop any random sounds that are attached to it.

If, on analysis of the printed log at the end of the game, you find that random sounds are being rejected too often, increase their maximum number by increasing the value for Max_random_sounds in  Concertina.h .




Fundamentals of Audio and Video Programming for Games
Fundamentals of Audio and Video Programming for Games (Pro-Developer)
ISBN: 073561945X
EAN: 2147483647
Year: 2003
Pages: 120

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net