2
\$\begingroup\$

I am pretty novice when it comes to game sound management, so excuse my ignorance.

I am having an issue when playing too many sounds at the same time where some sounds stop playing, or doesn't play at all, almost like some sounds overlap others. I've read some about the sounds using individual buffers and that there should be no problem playing these at the same time at runtime. When I only had a small ammount of sounds in the game, it all worked flawlessly. My SoundManager had no problem playing multiple sounds at the same time ( I loaded the sound to memory when I was going to play it and disposed it when it was done playing, approx. 5 seconds).

My SoundManager Class

I've recorded a video to better illustrate what this sound problem is. As you can hear in the video below, the attacking sounds can only be heard at some points, as for some enemy sounds. The idling sounds of the enemies (breathing and bat sounds) seem to work without issues, though.

Video

Thank you for helping, because I have no clue how to fix this issue. Is there something that I've left out in my SoundManager?

\$\endgroup\$
4
  • \$\begingroup\$ Maybe you have hit this wall: "The current upper limit for decoded audio is 1 MB." Also, when I worked on the audio of a project, I realized that there was a maximum number of concurrent sounds that could be played at the same time (I think they called it "channel"). It was in c++, on windows and involved OpenAL, so it might not apply to your situation. You should try to do a very small application to do just that: test the limitations of libgdx sound engine! \$\endgroup\$
    – Vaillancourt
    Commented Jul 31, 2015 at 11:59
  • \$\begingroup\$ Thank you for the tip! I've noticed that some audio files for the enemies was in fact over 1 MB in size, so I encoded the files from wav to mp3, decreasing the file sizes to under 500kb, is this the right way to go? \$\endgroup\$ Commented Jul 31, 2015 at 12:40
  • \$\begingroup\$ IMHO the important part here is decoded audio: event if your encode it in mp3, it will have to be decoded before being played. I'm not familiar with libgdx, but it seems there could be a bit more information with the doc I read. You could try and get a few more effects in by changing the 5 seconds hard coded value to something specific to the sound (e.g. your Manager is aware of all the sounds and their duration, or you could pass in a duration for the timeout as a playSoundEffect parameter). You could also try to reduce the quality (sampling rate, stereo -> mono) to save space. \$\endgroup\$
    – Vaillancourt
    Commented Jul 31, 2015 at 12:57
  • \$\begingroup\$ Okay, thank you. I just stumbled upon this tutorial: link where he uses a so called LRUCache to save up memory usage, I will try it out and report back the results. \$\endgroup\$ Commented Jul 31, 2015 at 14:05

1 Answer 1

2
\$\begingroup\$

After some research and testing, I've now managed to resolve my own issue.

The problem lied within memory management. I followed this tutorial Stiegert and got inspiration from his SoundManager class to create a new SoundManager of my own that uses LRU Caching.

Thanks Alexandre Vaillancourt for the assistance

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .