[Solved]Feature Request - SoundListener


03-03-2010 00:05:30

Hi Sticky! I have a feature request:

- Ability to attach a listener to a sound to receive notifications of certain sound events, for example I need a notification when a sound is destroyed.

The best example of this is the Ogre::Node::Listener class:

Listener ()
virtual ~Listener ()
virtual void nodeUpdated (const Node *)
Called when a node gets updated.

virtual void nodeDestroyed (const Node *)
Node is being destroyed.

virtual void nodeAttached (const Node *)
Node has been attached to a parent.

virtual void nodeDetached (const Node *)
Node has been detached from a parent.

What I currently need is a notification right before the sound is destroyed, but it would also be useful if we could have other notifications, something like this:

virtual void soundDestroyed(const Sound *)
virtual void soundStopped(const Sound *)
virtual void soundPaused(const Sound *)
virtual void soundResumed(const Sound* )
virtual void soundLooped(const Sound* )

Technically I will be the one writing code to stop/pause/play a sound, so that is not such a big deal, but getting notified when the OgreOggSound::Sound is being destroyed, or when a sound is looped, is very helpful. I hope you agree! :)


03-03-2010 08:01:03

Ah, I see there is already a function to provide a callback when the sound loops. I also see that ISound inherits from MovableObject, which has set/getUserAny and set/getListener. Looks like everything I need is already supported! No need to implement a Listener then. :)


04-03-2010 15:39:50

I recently found a need for this also so I think I may implement some sort of listener callback for stopping/pausing/playing events anyway, its particularly useful in the threaded version to synchronise things to the audio.


04-03-2010 19:09:46

IMO you should get rid of the loop callback method and implement support for a Listener, much more simple and less restrictive. :)


10-03-2010 20:36:27

Added listener interface, hope it fits your needs :wink:

Any ammendments let me know.