Android Question LibGDX Sound Issue

wonder

Expert
Licensed User
Longtime User
Hi Informatix,
I hope you had a nice Xmas!! :)

I'm working on a side-project, a small Pong clone, nothing complicated. I'm noticing a slight drop in the sprite animation (movement) performance every time I play a sound (filesize < 25kb).

Here's what I've tried so far:
- Using the Audio library's SoundPool (both mp3 and ogg) on the main thread.
- Using the Audio library's SoundPool (both mp3 and ogg) on the LibGDX thread.
- Using the LibGDX sound functions (both mp3 and ogg) on the main thread.
- Using the LibGDX sound functions (both mp3 and ogg) on the LibGDX thread.

The performance drop (kinda like the "screen tearing effect") is noticeable for all these methods. The only way for it not to happen is disabling all the sounds.

What could be happening?

Device: Asus ME173X (Tablet)
Android: 4.2.2
 

Informatix

Expert
Licensed User
Longtime User
I tried your Pong game on two devices and did not notice (visually) any slow down. As SoundPool may have issues on some devices (but it seems it's only on cheap Samsung devices), you should try to produce the sound with my OpenSL library to see if it's related to the used library.
 
Upvote 0

wonder

Expert
Licensed User
Longtime User
Thank you very much for your help! :)
I found your OpenSL lib yesterday and I understand that it works closer to the hardware level, so it should be faster!
I'm going to try it out right away!!

One question. Which thread should process sound, the LibGDX or the main one? I read somewhere that games should process sound in a separate thread. Is this correct?
 
Last edited:
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Thank you very much for your help! :)
I found your OpenSL lib yesterday and I understand that it works closer to the hardware level, so it should be faster!
I'm going to try it out right away!!

One question. Which thread should process sound, the LibGDX or the main one? I read somewhere that games should process sound in a separate thread. Is this correct?
AFAIK, all sounds/music are processed in their own thread whatever library you use. If not, your code should have to wait until the sound is fully played to continue.
 
Upvote 0

wonder

Expert
Licensed User
Longtime User
Thanks for the explanation on this matter!
Regarding the OpenSL lib, I got parasite "clicking" sounds at the end of each play and it didn't improve the performance.

I've achieved near optimal results by coming up with the following:
- Using the LibGDX integrated sound functions
- Using OGG files instead of WAV or MP3
- Reduced the OGG bitrate to 96Khz

So there it is, LibGDX playing 96Khz OGG files for optimal performance.
@Erel, consider this question solved.
 
Last edited:
Upvote 0
Top