Android Question LibGDX Sound Issue

wonder

Expert
Licensed 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
 

wonder

Expert
Licensed 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:

Informatix

Expert
Licensed 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.
 

wonder

Expert
Licensed 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:
Top