[AGDev-newbies] wav files

Thomas Ward tward1978 at earthlink.net
Thu May 4 23:20:12 BST 2006


Hi Richard.
I have a custome audio class written in C#.net I wrote to access 
Microsoft.DirectX.DirectSound.dll 9.0C.
The custom class I use is quite portable to any game engine written in 
C#.net. So that is why I wrote it that way.
One of the things I like about it this makes loading and playing sound 
effects a breeze. Here is an example of how my class works in a C#.net app.

// Load sound effects.
public void LoadSounds()
{

// Load sound 1.
g_audio.SoundOpen(1,
@"Sounds\Gun_Fire.wav");
}


// Start playing and looping the gun fire.
public void StartSounds()
{

// Start gun fire.
g_audio.SoundPlay1, true);
}


The SoundOpen and SoundPlay methods are a part of my Audio class in all 
my engines. All you have to pass is the number of the sound usually by a 
variable, and the file name or in the case of SoundPlay weather looping 
is true or false.
The same can be done for a C++ program if someone wishes to take the 
time to program such a C++ class for DirectSound 9.
The reason for doing this over directly accessing DirectX should be 
apparent. You don't have to recode the same thing over and over, and 
since you are giving each buffer a number id rather than a name like 
g_dsGunFire you can name that buffer whatever you want per game, and 
actually rename it mid game.
Anyway, that is how I do it.



More information about the AGDev-newbies mailing list