Jump to content

EmitSound() doesn't clear Source when Listener is outside of range


Recommended Posts

I noticed something interesting earlier today and have been testing it. Seems consistent in what goes wrong (all in C++ btw):
I have doors that make a sound when they open or close. I've currently switched to using EmitSound() for this with a range of 10, no looping or pitch changes. The sounds are loaded with Sound::Load() on the door actor Attach() and released on Detach().

When standing within the range of the door (10) and open/close it the sound plays, adding 1 Source to the list, then after it's done the Source is released and the list shrinks by 1 again. From what I've gathered this is expected behavior.

However I've noticed that if I open/close the door, then run away until I'm out of range the Source does not seem to be cleared as the list is not decremented by 1.
I also noticed that when I'm standing outside of the range and the door auto-closes, thus playing the close sound, the Sources list is also not decremented.
I've noticed similar behavior with other entities. There's an AI running around the map, which makes a sound when it performs a certain action using EmitSound(), looking at the Debug console I clearly see the Sources list incrementing every time. I've tried loading the sound when doing the action/triggering a door open or close, then releasing it after the EmitSound() call but this made no difference.

I'm aware I could use create a Source in the door actor, but since some levels have dozens of doors this really stacks up. It's what I used so far but I noticed that a lot of Sources causes sound issues. At this point I'm just wondering if I should make a few dedicated sources in the player actor instead and use these to play all the sounds near the player, though that would require a bit of setup and management which honestly the engine should handle, right? :)

Sorry to keep hammering about these sound issues, but our game relies heavily on sounds for atmosphere and cues, plus I do want LeadWerks to improve one final time haha

Link to comment
Share on other sites

10 hours ago, EvilTurtleProductions said:

Sorry to keep hammering about these sound issues, but our game relies heavily on sounds for atmosphere and cues, plus I do want LeadWerks to improve one final time haha

I can't recommend FMOD enough.

Not sure why Sources are getting stuck in memory, I assumed it would handle itself.

If you still want to use OpenAL, I recommend making a base actor class to manage sounds how you want them to be managed.

 

  • Like 1

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...