Android audio: Does it work?

About a year ago, when I first released my app Blocfall, I decided not to do an Android build because the audio didn’t work well. The sound effects I had linked to touch events lagged the visuals by about half a second, enough to make the game look bad.

On a recent app build I did for Kindle, the problem remains: The sound effects lag.

Is there a way to remedy this?

The lag does not happen on iOS builds and the audio .wav files are the same. The .wav effects files are also well trimmed so there’s no silence padding before the effect.

This doesn’t seem to be anything that can be optimized by better coding. The call to play the sound isn’t buried somewhere:

-- if 1 then remove block and show explosion  
if enemyList[enemyID].val == 1 then  
  
 if (audioOn == 1) then  
 playSound(sounds.boomSound) --should play as explosion occurs but lags  
 end  
 enemyList[enemyID].val = 0  
 enemyList[enemyID].lock = 1  
 enemyList[enemyID].isVisible = false  
 local addScore = score()  
 points = points + addScore  
  
 -- display explosion  
 local ax = enemyList[enemyID].x  
 local ay = enemyList[enemyID].y  
 fire (ax, ay)  
...  

Is Android audio really so bad it can’t manage to play a simple sound effect without a delay? Or is there something I’m missing? A different audio format maybe? [import]uid: 1560 topic_id: 25513 reply_id: 325513[/import]

Ansca staffers have posted several times that this is an Android “feature” and that audio is just laggy on that platform and there is nothing that can be done about it.
[import]uid: 19626 topic_id: 25513 reply_id: 103092[/import]

Yes, Android is that bad.

http://code.google.com/p/android/issues/detail?id=3434
http://kile.stravaganza.org/blog/post/android-audio-api-sucks
http://www.badlogicgames.com/wordpress/?p=1315
http://groups.google.com/group/android-ndk/browse_thread/thread/29f88a99dc954c71
http://mindtherobot.com/blog/555/android-audio-problems-hidden-limitations-and-opensl-es/
http://music.columbia.edu/pipermail/portaudio/2010-December/011146.html

But your experience will vary greatly depending on your specific device, OS version, and current CPU utilization. Some devices are much better than others, while we’ve seen some devices not work at all.

You might try lowering the sample quality as suggested in the Audio Notes page and try to do things that lower your total CPU utilization while playing sounds.
There might be a few things we can do to improve it, but you guys need to make some decisions and let us know. Android is trying to improve things by providing a new NDK-only API called OpenSL ES. But it is only available starting in 2.3. (And some of the new native sound decoding APIs like for mp4 may not be available until 4.0.) OpenSL ES won’t solve all problems, because Google admits the latency problems are also in the kernel/OS itself which means you need OS updates as Google fixes things.

But the 2.3 minimum makes it very hard for us to start work on because we get a lot of complaints about wanting backwards compatibility (we still hear a few people complain about armv6). As I posted here http://developer.anscamobile.com/forum/2012/03/22/43-corona-704-do-i-have-freeze-my-xcode-version, backwards compatibility can be an expensive feature. We understand Android is very different than iOS so we aren’t applying the same metrics to decide when to version bump as in iOS, but in my opinion, the 2.2 requirement is holding a lot of things back.

So you the community need to help us decide (though we’re not actually making any decisions right now).

  1. how important is audio to improve on Android (i.e. general time resources we should dedicate vs. other issues) and

  2. when it is okay to move beyond 2.2 (or any other version for that matter).

Last I checked, Google’s numbers show 2.2 makes up about 25% right now. I think Corona numbers might be lower because we don’t support armv6 which tends to inflate the number of 2.2 devices.

[import]uid: 7563 topic_id: 25513 reply_id: 103095[/import]

Not that I have any say in the matter, but with Android pushing 4.x, holding on to 2.2 seems like a painful process.

I would also bet that people running 2.2 are not app buyers anyway. Lets face it, app buyers tend to update their hardware more frequently and apply system patches. Those that don’t are just using the phone as is for the most part.

Audio is important to games. But in many cases a little lag doesn’t hurt that much, but in others it completely ruins the experience. Like everything in life, there has to be a balance and finding that balance can be tough.
If my vote counted for anything, I’d say drop 2.2. Apply what audio fixes you can that are easy and reasonable. [import]uid: 19626 topic_id: 25513 reply_id: 103103[/import]

My Kindle Fire is 2.3.4 and I’ve never applied an update. Though I did get a referb model right about the time Amazon announced updates software for it.
[import]uid: 19626 topic_id: 25513 reply_id: 103118[/import]

The Kindle is a 2.3 device, not a 2.2.

But, the Kindle has very low-end/poor hardware. The latency issues we have seen are worse on a Kindle. (Even Angry Birds seemed to have a large latency when I tried it.)

[import]uid: 7563 topic_id: 25513 reply_id: 103124[/import]

Thanks for the feedback.

The problem with moving to 2.3 is that the Kindle Fire is presently Android 2.2 and it’s a meaningful market. Small wonder Apple keeps turning in record revenue reports.

Perhaps I’ll just add a separate sound effect button and tell users they have to tap it about half a second before they blow anything up on-screen in order to get sync sound :wink:

Correction: You’re right, 2.3 not 2.2. [import]uid: 1560 topic_id: 25513 reply_id: 103112[/import]

By the way, you guys do have say in the matter. If enough of you say 2.2 is not worth it, then we can move on. (The feedback from you guys who were actually publishing apps led to the armv6 being dropped. Bad reviews from users on poor devices were hurting your ability to monazite. Guaranteeing a level of quality trumped catering to marginal devices for you guys in this case. We listened.)

[import]uid: 7563 topic_id: 25513 reply_id: 103131[/import]