Question about sources limitation

pra

26-02-2008 13:54:49

Just a few questions:
-what exactly is the sources limit? Does it prevent me from creating new OgreAL::Sound objects, or does it just limit the number of sounds that are actually playing/that can play at the same time?

-should I create a new Sound object each time I need to play something and then destroy it, or should I pre-create objects for sounds I might need somewhen and keep them until then?

CaseyB

26-02-2008 16:54:24

The source limitations only limit how many sounds play at once, you can create as many Sounds as you like. As for creating and keeping around vs. creating and destroying it really depends on your application. Sounds don't hold on to their sources when they aren't playing, so you don't lose anything by keeping them around, but there isn't much overhead in destroying and creating them within reason. I mean it wouldn't do to create/destroy a Sound several times a second, but periodically is not bad.

pra

26-02-2008 18:04:06

thanks, that makes things clearer

i was thinking of keeping sounds like footsteps, and create a weapon sound as soon as the weapon is equipped and keeping it then.

If i try to play a sound while alerady having as much as the limit, will it be just unhearable/refuse to play, or does it throw exceptions?

CaseyB

26-02-2008 18:47:40

It won't throw an exception. When you play a Sound it sees if there are any sources left in the pool, if there are then it allocates one, no problems. If there are no sources left in the pool then it looks at the Sounds that are playing and compares their priority and distance from the listener to the priority and distance from the listener of the Sound that wants to play. If there are Sounds playing that are at a lower priority than the Sound that wants to play it will steal the source from the lower priority Sound that is farthest from the listener. If they are all at the same priority then it checks based on distance and if there are Sounds playing that are farther from the listener than the Sound that wants to play it will steal the source from the Sound that is farthest from the listener. I do this to try to steal sources from Sounds in a way that is less likely to be noticed.

pra

02-03-2008 15:44:41

works so far, but is there a way to test if a file is a valid sound? I noticed OgreAL won't play RIFF-WAVs, although I can create an OgreAL::Sound object from such a file (it throws an exception later, what makes it a little difficult to find the problem).

And I also noticed that there is a little lag if I create a new sound object for a longer sound (in this case: in-game music), at least on this slow laptop. If I pre-create sounds for my music, will it pre-load the audio files? If yes, what about RAM usage?
Streaming seems to stop for a short period of time if the whole application does something what causes a lag (i.e. generating CEGUI windows while in debug mode). That wouldn't be much of a problem, but Sound::isStopped() returns true in that period... Is there something like a isDonePlaying() function?

edit: i noticed that resuming Sound::pause() only works for streaming sounds, otherwise it just starts from the beginning...

Deamon

06-04-2008 08:41:12

btw how many sounds can I play at once ?

Elenssar

07-04-2008 09:09:34

Hi pra,
Did you manage to solve the "isStopped()" during streaming time?,
I turn off streaming, but now I suffering it in loading time.
May be there is a AL_SOURCE_STATE that check if the sound is streming?

pra

07-04-2008 14:04:52

no, i just decided not to use streaming...