Step 11


Playing a special effect on a sound buffer is a two-stage process. First, the effect is attached to the sound, and then that effect is activated. The theory is that you may want to attach a number of effects to a sound, but only turn on certain ones for a particular rendition of that sound buffer.

You can use two different options to attach a special effect, using one overloaded method.

 bool attachSpecialEffect (soundBufferRef* sID, SFXID fxID);  bool attachSpecialEffect (soundBufferRef* sID, ESFXType type,                            char paramString[]); 

The first option is simple; enter the ID of the sound buffer and the ID of the preset special effect. For example, the following two lines of code attach a preset distortion and flanger effect to an engine sound identified by sIDEngine .

 Concertina.attachSpecialEffect(&sIDEngine,SFXID_distortion1);  Concertina.attachSpecialEffect(&sIDEngine,SFXID_flanger1); 

Here is an alternative method of attaching a special effect, using distortion as an example.

 Concertina.attachSpecialEffect(&sIDEngine, eSFX_distortion,                 "0.0f  15.0f  2400.0f    2400.0f    7350.0f"); 

In this case, we identify that it is a distortion effect by the eSFX_distortion enumeration member, and then enter a string of text matching the required parameters for this effect. It might be helpful to add a comment preceding a line of code like this, identifying each entry.

 Concertina.attachSpecialEffect(&sIDEngine, eSFX_distortion,  //              gain  edge   frequency  bandwidth  cutoff                 "0.0f  15.0f  2400.0f    2400.0f    7350.0f"); 

You can attach one of each special effect type to any one sound buffer. You can play a sound buffer with any number of these types activated. To activate a range of special effects, call the following method.

 bool activateSpecialEffects(soundBufferRef* sID, ESFXType e1,                              ESFXType e2 = eSFX_dud,                              ESFXType e3 = eSFX_dud,                              ESFXType e4 = eSFX_dud,                              ESFXType e5 = eSFX_dud); 

This method will allow you to activate up to five special effects. You could redefine it with more parameters if there are cases where more than five need to be activated for one playing (or simply call this method twice).

To call this method to activate a distortion effect, use the following code.

 Concertina.activateSpecialEffects(&sIDEngine,eSFX_distortion); 

Or, use the following to activate an echo and a flanger effect.

 Concertina.activateSpecialEffects(&sIDEngine,eSFX_echo,eSFX_flanger); 

The call to activateSpecialEffects must be made before the sound buffer starts playing. Typically, you would keep the two lines of code together.

 Concertina.activateSpecialEffects(&sIDEngine eSFX_distortion);  Concertina.play3DSoundBuffer(&sIDEngine true); 

To summarize, the process of adding special effects has been reduced to three steps by the Concertina framework, defining the special effect parameters in the form of an enumeration and text string, attaching one or more effects to a sound, and then activating some or all of the attached special effects before playing that sound.




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