Sounds are insane?

Is it just me, or are sounds incomprehensibly insanely coded?

If I call, say, this code in some function

self.s = loader.loadSfx("x")

everything seems to work fine.

However, if I call that without the self, the sound stops playing as soon as the function is over.

That doesn’t sound like the way it should be. Sounds should be tracked by the sound manager, and the variable should be a mere pointer to what the sound manager knows. Once the variable goes out of scope, the sound is destroyed. Was this intentional? Is there a way around it? Because it sounds crazy. We should not be forced to keep track of all our sounds, fire and forget is much cleaner.

Use a SoundInterval if you want fire-and-forget behavior.


Honestly, I agree that the this behavior is a little weird. It has to do with the panda reference counting garbage collector - the sound is getting garbage collected when the last pointer goes away. Generally, as a old LISP hacker, I adhere to the philosophy that the garbage collector should not change the semantics of a program. This is a violation of that rule.

We could increment the reference count of a sound while that sound is playing, and decrement it afterward. I may well do this in the OpenAL audio manager.

Thanks. I think that there should be some reference to the soundinterval in the sounds section of the manual, or if I missed it somehow, a better explained reference. When I needed to know about the sounds, I checked the section labeled “Sounds”, not “Intervals.”

This might actually be a bug in the OpenAL audio manager. I need to fix this.