Fundamentals of Audio and Video Programming for Games (Pro-Developer)
Now you need to come up with the special effects settings that you will apply to the sounds throughout the game. The concept of the design here is to make it simple to attach special effects to a sound buffer. As with the other initialization procedures, you need to prepare an enumeration and a structure, which in this case are called SFXID and presetSpecialEffect , respectively. The enumeration provides IDs that call up any one of the effects, and the structure has a string format making it easy to enter values.
enum SFXID{ SFXID_environment1 = 0, SFXID_environment2, SFXID_chorus1, SFXID_chorus2, SFXID_compressor1, SFXID_distortion1, SFXID_echo1, SFXID_flanger1, SFXID_gargle1, SFXID_parameq1, SFXID_parameq2, SFXID_reverb1, // Terminate the enumeration with this value. SFXID_end };
You can define as many special effects of one type that you want. The definition is provided in a genericSoundEffectStruct structure. Refer to this structure in the
// wetdry feedback leftdelay rightdelay pan { SFXID_echo1, eSFX_echo, "50.0f 50.0f 500.0f 500.0f 0"},
Note that the first entry is the ID from the SFXID enumeration, and the second is the type of effect from the ESFXType enumeration that we used extensively with the Rumpus 3D SFX tool (defined in the
The main use of the structure is in the easy entry of values in the form of a string. All floating point values should be entered with an ending f, and all integers entered just as they appear. This makes it easy to scan the string and enter the values. The purpose of this string is ease-of-use; you can enter as many effects as you like into the structure and enumeration by copying the format of the strings that are already provided.
The goal is pain-free special-effect attachment. You are not limited to using the special effects as defined, but the methods provided in the framework make it very easy to attach one of these predefined effects to a buffer.
Hopefully, you have used the Rumpus tool, and referred to the chapters on special effects settings to create precisely the settings that you prefer.
One limitation of our implementation is that each sound buffer can only have one of each type of effect applied. If this turns out to be a problem, as it would be if you want to attach two echo effects, or three parametric equalizers, to one sound buffer, then you will have to adapt the code. Step 11 describes the methods used to attach special effects to a buffer, and discusses how to use effects that are not defined in the preset table.