New Android Audio Lag

There are two ways to play Audio. The audio.* api calls and the media.* api calls.

Audio is the better way (in most cases) because it’s using OpenAL, pushing hardware support to the OS and not to the app (or Corona SDK in this case). You get multiple channels, ability to control volume on each channel, etc. It’s much better than the media.* API’s because you can’t blend sounds etc.

However on Android, they have poorly implemented OpenAL and sounds lag a little bit. Since media.* works directly with the hardware, it can play short sounds faster. If you’re app requires more accurate sound timing, you probably should use media.* instead of audio.*.

But if dealing with this lag, isn’t that big of a deal, audio.* is the much better way to play sounds.
[import]uid: 199310 topic_id: 33649 reply_id: 140982[/import]

Thank you for keeping an eye on this thread Rob. I am curious about something. Corona SDK is a pretty large and successful platform. Have you guys got enough clout to have a dialogue with Google about this and them fixing the problem? It seems like something they should get onto fixing ASAP years ago. [import]uid: 92709 topic_id: 33649 reply_id: 140985[/import]

Maybe unity and Moai just use the equiavlent of a media API so no audio API lag issues to worry about? I dunno. [import]uid: 92709 topic_id: 33649 reply_id: 141010[/import]

@rob

This page says not to use the media api anymore (replaced by OpenAL library:
http://docs.coronalabs.com/api/library/media/index.html

You know if wav files would be better on Android? We still have a 500ms delay when playing on Kindle Fire and Nook. But we use mp3 files.
[import]uid: 50459 topic_id: 33649 reply_id: 140907[/import]

I feel like I tried wav files a long time ago and it didn’t improve the lag. I’ve been with Corona for a few years now and this Android audio lag issue has always been around, don’t expect it to get resolved anytime soon. For my Android builds I have had to change all my audio calls to use the media api instead of the openAL library to try and make the Android audio have less of a delay. [import]uid: 19620 topic_id: 33649 reply_id: 140909[/import]

I can also confirm that I’m only using wav files. The audio API used to work fine before they ‘improved’ it. But now I am using the Media API and it seems to work fine although i miss the features of the Audio API. This really should be fixed. There was no problem with the AUdio API before on my devices so surely they can just do whatever they were doing now across all Android devices. It boggles my mind how such a mature development platform could have such a crazy issue. I’m sure it’s Android’s fault as well but the point is, IT DID WORK FOR ME BEFORE! [import]uid: 92709 topic_id: 33649 reply_id: 140948[/import]

There are two ways to play Audio. The audio.* api calls and the media.* api calls.

Audio is the better way (in most cases) because it’s using OpenAL, pushing hardware support to the OS and not to the app (or Corona SDK in this case). You get multiple channels, ability to control volume on each channel, etc. It’s much better than the media.* API’s because you can’t blend sounds etc.

However on Android, they have poorly implemented OpenAL and sounds lag a little bit. Since media.* works directly with the hardware, it can play short sounds faster. If you’re app requires more accurate sound timing, you probably should use media.* instead of audio.*.

But if dealing with this lag, isn’t that big of a deal, audio.* is the much better way to play sounds.
[import]uid: 199310 topic_id: 33649 reply_id: 140982[/import]

Thank you for keeping an eye on this thread Rob. I am curious about something. Corona SDK is a pretty large and successful platform. Have you guys got enough clout to have a dialogue with Google about this and them fixing the problem? It seems like something they should get onto fixing ASAP years ago. [import]uid: 92709 topic_id: 33649 reply_id: 140985[/import]

Maybe unity and Moai just use the equiavlent of a media API so no audio API lag issues to worry about? I dunno. [import]uid: 92709 topic_id: 33649 reply_id: 141010[/import]

I must scratch that comment. It looks like a Corona specific problem and not the case where other SDKs use the Media API. Many android games on the market handle multiple sounds at once. The Media API cuts sounds off if you play too many it seems.

I would still like to know if Corona is able to talk to Google about this and have they?

[import]uid: 92709 topic_id: 33649 reply_id: 143007[/import]

I must scratch that comment. It looks like a Corona specific problem and not the case where other SDKs use the Media API. Many android games on the market handle multiple sounds at once. The Media API cuts sounds off if you play too many it seems.

I would still like to know if Corona is able to talk to Google about this and have they?

[import]uid: 92709 topic_id: 33649 reply_id: 143007[/import]

I must scratch that comment. It looks like a Corona specific problem and not the case where other SDKs use the Media API. Many android games on the market handle multiple sounds at once. The Media API cuts sounds off if you play too many it seems.

I would still like to know if Corona is able to talk to Google about this and have they?

[import]uid: 92709 topic_id: 33649 reply_id: 143007[/import]

I must scratch that comment. It looks like a Corona specific problem and not the case where other SDKs use the Media API. Many android games on the market handle multiple sounds at once. The Media API cuts sounds off if you play too many it seems.

I would still like to know if Corona is able to talk to Google about this and have they?

[import]uid: 92709 topic_id: 33649 reply_id: 143007[/import]

I was wondering if there is a fix for this problem? Our app has 1 second delay on Android devices because of Corona. 

What can we do about it? 

I’m having the exact same problem.  I’m trying to provide some form of click feedback when a user clicks on (virtual) keys, but the lag is so bad even with a 45ms audio file, that it’s completely useless.  I’d love to use the system.vibrate function for this, but like many other items, this too has also been very poorly implemented by Corona.  There is no way to set the strength of the vibration and it appears that Corona has it cranked to the maximum by default which emits a loud and annoying buzzing sound on most tablets and phones that we’ve tried. I need basic tactile feedback, something that all the competing apps to mine offer, and it’s an embarrassment that this can’t be done with Corona.

These are extremely basic and fundamental functions (not just nice-to-haves) and it’s difficult to understand why Corona has ignored these for so long – especially as this is primarily a gaming platform. Corona seriously needs to dedicate a developer to fix a few very fundamental functions like system.vibrate (strength), audio.play (eliminate lag) and (perhaps the most difficult to understand) provide the ability to programmatically copy/read text to/from the clipboard (and after 3 years of countless users requesting this).  How could anyone take Corona seriously as a platform for developing business apps, when text can’t even be copied/pasted to/from the clipboard?  This functionality for plain text is only about 3 to 10 lines of native code on each respective platform.

Google did fix it in Android 4.1 (I think).

I’ve got a Nexus 7 with Android 4.2.2, and the audio lag is as good as gone. Compared to iOS which has no lag whatsoever, the Android device still has a short lag, although barely noticeable during gameplay unless you look/listen for it.

Google still has some work to do to get it completely eliminated…

> I’ve got a Nexus 7 with Android 4.2.2, and the audio
> lag is as good as gone. … the Android device still

> has a short lag,

If you’re just playing a music file, “a short lag” might be equatable to “good as gone,” but for games where a laser sound (‘pew pew pew’) is supposed to sync up with the user hitting a button or a business app where key-click sounds should coincide with pressing of keys, a 500ms to 750ms lag is completely unacceptable.

I’m *not* talking about music files, I’m talking about games with a laser sounds (‘pew pew pew’) and the like.

I’d estimate the lag in the latest versions of Android to be <100ms.

…and this is an Android problem, not Corona SDK.

I don’t understand how google could have messed up so much. But on the other hand I still feel that Corona is somewhat at fault. I had no lag on my s1 so it was possible before 4.2.2. Anyway, it’s kind of useless since most phones aren’t on the latest android version.

I just have to accept sounds cutting off sometimes with the media api, that’s all.