0
0

I have a cross-platform mobile game project that runs on both iOS and Android. On iOS, the audio is perfect, but on Android, the audio becomes very choppy when several sounds are playing. I’ve worked with FMOD on iOS previously, but this is my first Android project.

Here is our Android setup:
[list:zts5jnv7]
[:zts5jnv7]Using AudioTrack rather than OpenSL (mostly so we could easily start and stop the audio when the app was backgrounded)[/:zts5jnv7]
[:zts5jnv7]Running at a low bitrate (20000)[/:zts5jnv7]
[:zts5jnv7]I have doubled the default buffer size and number of buffers (was this wise?)[/:zts5jnv7]
[:zts5jnv7]The app uses the cocos2d-x framework; FMOD is started and called on cocos2d’s thread[/:zts5jnv7]
[:zts5jnv7]Not sure if this is significant: we’re using the FMOD Event system, and it’s pumped as a cocos2d scheduled update[/:zts5jnv7]
[/list:u:zts5jnv7]

One thing I haven’t ascertained yet is whether it’s really multiple sounds that trigger the choppiness, or whether it’s actually happening when the CPU is under load.

I’m really just looking for advice on where to go from here in trying to eliminate the choppiness. Some ideas:
[list:zts5jnv7]
[:zts5jnv7]Should I be looking into moving FMOD initialisation and calls onto their own thread? This obviously has some pretty major ramifications for the code structure.[/:zts5jnv7]
[:zts5jnv7]Is there any benefit to running the Java FMODAudioDevice on its own thread, or perhaps on the Android UI thread? I’m not really clear on what the AudioDevice does (other than that it’s required for AudioTrack).[/:zts5jnv7]
[:zts5jnv7]Is there a way for me to get a better picture of what’s causing the choppiness? (E.g. is it really multiple sounds? CPU under load?)[/:zts5jnv7]
[/list:u:zts5jnv7]

Thanks in advance, everyone! I’ll really appreciate some pointers on where to go from here.

  • You must to post comments
0
0

[quote:37z5hgty]I have doubled the default buffer size and number of buffers[/quote:37z5hgty]
This is often necessary on Android to overcome stuttering, you should adjust the buffers until you strike a good balance between stable playback and acceptable latency.

[quote:37z5hgty]Should I be looking into moving FMOD initialisation and calls onto their own thread? [/quote:37z5hgty]
No, it is safe to init FMOD on any thread, however you should keep all your FMOD calls on that same thread to avoid synchronization issues.

[quote:37z5hgty]Is there any benefit to running the Java FMODAudioDevice on its own thread, or perhaps on the Android UI thread?[/quote:37z5hgty]
No, internally FMODAudioDevice is a small piece of code that will create its own thread for passing audio from FMOD to Java.

[quote:37z5hgty]Is there a way for me to get a better picture of what’s causing the choppiness?[/quote:37z5hgty]
Yes, try System::getCPUUsage, as the CPU load approaches 100% things will start to sound choppy, which I believe your problem will be. I would recommend re-evaluating how many sounds you are playing at once, what DSP effects you are using and your choice of compression for audio. If you can report back your usage I might be able to advise some changes.

  • You must to post comments
0
0

[quote="mathew":1ots78qv]I would recommend re-evaluating how many sounds you are playing at once, what DSP effects you are using and your choice of compression for audio.[/quote:1ots78qv]

I figured that a different compression method should be my first port of call. Two of the fsb banks were already using ADPCM, but the third was on MP2. I changed it to ADPCM and, lo and behold, all stuttering was cured! Fortunately, we have a bit more of a disk space and RAM budget for audio on Android compared to iOS, so this is a change I can afford to make. In fact, I think the Android sound quality is now [i:1ots78qv]better[/i:1ots78qv] than on iOS, which I never thought I’d hear happen.

Thanks for your great suggestions, Mathew — this one turned out to be easier than I thought, but I really benefitted from your expertise. Cheers and have a great Christmas. :)

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.