how do i make active inactive sounds?

I am having problems of putting more sounds then i want into the game. Actually i even don’t want to play all the sounds if i could because it turns into noise.

I try do setActive(false) no sounds i don’t want to play right now and setActive(true) on sounds that that i do want playing right now. Does this free up the load on the sound managers? (Fmod or openAL?) I am still having them crash with over 150 inactive sounds and only 12 active.

Now next problem is that when sound is inactive its time pointer is not moving but is stuck. Only when its active, its start to play and time pointer moves.

How would i keep the sound time pointer moving and behaving like its playing, without actually burdening sound manager and player ears with it?

What do you mean by “not active”? If the sound is playing, meaning its time pointer is moving, then it is active, and counts against you. If you want the time pointer to move, you have to have the sound actually playing (because it is the sound hardware that is actually pushing the time pointer).

Calling setActive() should effectively stop the sound and remove it from the number of sounds that count against you. Calling stop() should have the same effect. I can’t speak for either the FMod or the OpenAL implementations, since I had nothing to do with these and my experience is with the Miles implementation, but that is at least the intended design.


Speaking of sound systems, Panda’s OpenAL implementation is far from perfect. Could we just enable FMOD in the default build? Or, even better, would it be an idea to enable Miles in the default build?

I’ve got no problem with enabling FMod in the default build; I thought it was the default already.

As to offering Miles, it’s not really an option, since Miles doesn’t offer a free-for-nonprofit-use like FMod offers.


I think panda3d’s openal audiomanager is fine. It is the openal implementation itself, i.e. the libopenal against which panda is linked, that is lacking.

The standard implementation of openal has been neglected for a long time, but someone is making significant improvements in the “OpenAL Soft” fork:

It may be worth the effort to see if panda3d could use this implementation of OpenAL. Especially since its advantage over fmod is that it is open source. Also, its maintainer is active and might be willing to fix any bugs that come up.

I compiled openal-soft and replaced libpandaopenal.a in panda3d 1.5.4. It works! Now I finally have correctly working doppler shifts with openal :slight_smile: . One thing I had to do was copy the example config file and set the output to alsa device “surround51”, for my speaker setup under linux.

This is really a better implementation of openal for linux, so I would recommend including this one with panda3d.

Openal-soft also has a reverb effect and a low-pass filter. I will try to get that working with panda3d.
I am willing to look into a few other problems there may be with panda’s openal AudioManager. The problem mentioned in this thread requires creating an intelligent pool of audio Sources, so that’s a bit too involved for me. treeform mentioned in another thread that looping is not working correctly. Anything else?

Great work! :slight_smile:
If you can get everything working and stable I’d be happy to include this instead of the current version of OpenAL. That is, if the license permits it.
Is this implementation also available for linux?

OK, I will test it a bit!

The license is lgpl, so it is compatible with panda3d. I use it now on linux. mentions: “for use on Linux and various other Unices. Can also be used on Windows.”

Laurens, i already create an overly intelligent sound manager in python. If only i had controls to manage the sound and the sources from python i could create anything. It would be great to have some sort of an api where i can load sounds and then attach them to sources when I want them to play and detach them when they are too far way or there is some thing more important to play.

I am reading through the source of panda’s OpenALAudioManager, and I think everything you need is already there. You can set the maximum number of playing sources by calling myAudioManager.setConcurrentSoundLimit(number). The default number is 0, meaning unlimited. If the maximum number of sounds are playing and you start another one, the oldest sound is stopped.
There is a cache of sources. If you stop a sound, its source is put in the cache. If you start a sound, a source from the cache is reused or if none are available a new one is made.

So by simply calling play()/stop() on a sound, a source is attached/detached using the cache. What you want to do differently when the maximum number of playing sounds is reached, is not to remove the oldest sound, but do something more intelligent using your python audio manager. Note that FmodAudioManager does not have such a cache system (maybe fmod does something similar itself, I don’t know).

On setActive(). With setActive(False) you “pause” a sound, remembering its state (playing/paused/stopped). For example, if you have an audioManager for all the sounds in your game and the user pauses the game, you can call audioManager.setActive(False). All sounds stop playing. If the user continues the game, you call audioManager.setActive(True): all sounds that were playing before, continue playing. But all the sounds that were paused, stay paused.

So you cannot use setActive in the way you describe at the start of the thread. Your python audiomanager will have to keep the time for each sound it temporarily removes.