Overview of how to use.

mkultra333

07-11-2010 17:20:34

How should I use OgreOggSound for my first person shooter? So you'll have the typical stuff: Some monsters running about firing weapons, the player's footsteps and firing his own weapons, explosions from missiles and bombs, doors opening, picking up health, beeping computers, etc.

1) It looks like the default is for there to be 100 sounds. Can I play all of them at once? Do I have to worry about some sound cards crashing because they can't handle that many sounds?

2) I've successfully got sounds loading and playing in 3D space. Do I initially set up and ration all the sounds I'm going to use? For instance, budget for 3 explosions, 6 firing guns, 2 beeping computers, etc. Then as the game plays, if it happens that there are 4 explosions and 5 firing guns in one scene, will I just have to miss out on one of the explosions?

3) I see mention in the API of "sources" and of getting/setting a sounds "source." What's the use of this? There doesn't seem to be any function to create sources, so how does this work? Can I set up a source and then have multiple sounds all playing from the same source?

Number 2 would be the naive way I'd approach the game sound issue, I'm just wondering if that's correct, or if number 3 means there's a better way.

stickymango

08-11-2010 11:57:35

Hi There,

Sources equate to simultaneous playing sounds and is hardware defined. That could range from as little as 16 sounds up to 256 or maybe more?

You can create as many sounds as you like but you'll only ever be able to play [Source count] sounds at any one time, the manager should handle this by using a round-robin system to play the [source count] most important sounds, based on distance/priority settings.

You can only bind one sound source per source object, so if you want to hear 3/4 explosions then you will need to create 4 explosion sounds, the audio data will be shared among them, provided you create them as Static sounds.

As for creating all sounds up front, that would be the preferred method to prevent any stalling issues in game while a sound is created/loaded, however the multi-threaded version is designed to minimize this by cueing the loading/playing of the sound through the second thread, so it should be possible to dynamically create/destroy sounds in-game, there's also a nifty 'temporary sound' feature where you can specify a sound to auto-destroy itself after its played, so you could blindly create 'one-shot' sounds and the manager will handle the destruction in the background for you..

HTH