New Android Audio Lag

I recently upgraded to the latest public build: CoronaSDK-2012.971.

I have noticed that my Android app now has a significant delay for all audio sounds. This was not the case with the previous public build. Previous versions of my app had no audio lag but now it is severe. I have a Galaxy S3 so it’s not a speed issue as even the SimplePoolPlus example has the same delay.

Has anyone else noticed anything? This delay is extreme and I could never release my app like this :frowning: [import]uid: 92709 topic_id: 33649 reply_id: 333649[/import]

After some research, it appears that this is caused by a switch from AudioTrack to OpenSL-ES. I’m not sure what issues there was with AudioTrack but I never noticed anything (it was perfect!) whereas I really notice this new audio lag.

After some testing, it appears that the audio lag is about 150-200ms although it sounds really off.

Perhaps there is a way to force my app to use AudioTrack? I was going to buy Corona Pro but I simply cannot do this if my audio lag is so extreme. Or perhaps it can be fixed in an upcoming build? [import]uid: 92709 topic_id: 33649 reply_id: 133797[/import]

After some research, it appears that this is caused by a switch from AudioTrack to OpenSL-ES. I’m not sure what issues there was with AudioTrack but I never noticed anything (it was perfect!) whereas I really notice this new audio lag.

After some testing, it appears that the audio lag is about 150-200ms although it sounds really off.

Perhaps there is a way to force my app to use AudioTrack? I was going to buy Corona Pro but I simply cannot do this if my audio lag is so extreme. Or perhaps it can be fixed in an upcoming build? [import]uid: 92709 topic_id: 33649 reply_id: 133797[/import]

I have always found android with corona to have terrible audio lag. Its always been this way, really disappointing. Doubt this will change anytime soon, so I’ll be looking at another SDK besides corona for future apps [import]uid: 19620 topic_id: 33649 reply_id: 135295[/import]

It shouldn’t be necessary switch. Any audio lag in the past wasn’t noticeable. It’s only because of this change that tried to improve the audio. Now it’s crazy. I’m disappointed that there hasn’t been any response to this from the developers. Audio sync is a priority issue.

Interestingly, this lag doesn’t happen on My Galaxy S 2.3.3. [import]uid: 92709 topic_id: 33649 reply_id: 135303[/import]

I have always had problems with Audio lag on Android using the Audio.* API. However I have the opposite experience with the latest builds. For me the lag issue in the Audio API has been vastly improved.

I have a Galaxy S (1st gen) and a Google Nexus as test devices for Android.

With the new release there is still a lag though, and I would estimate that to about 150-200ms as you’ve also done, but previously it was closer to 800ms when using the Audio API.
I use the Media.* API for short sound effects to reduce this lag, however the lag is still around 100ms.
The recommendation from CoronaLabs is still to use the Media API for short sounds on Android.

My understanding is that Corona Labs have done as much as they can to minimize this lag. Whatever lag that’s left is the different implementations of Android done by the device manufacturers.

[import]uid: 70847 topic_id: 33649 reply_id: 135305[/import]

Yeah, my first generation Galaxy S is fine. I just wish could revert to using the old audio api, that’s all. It worked on both my devices. I’ll have to try the media API I guess. This issue is amazing and if it is such a problem using another development API shouldn’t help right?

I just don’t get how it worked fine for me before but is now broken… [import]uid: 92709 topic_id: 33649 reply_id: 135309[/import]

This question gets asked a lot, and I think the current recommendation is for time sensitive, short clips, to use the media.* library on Android only and use audio.* on iOS and on Android for non-time sensitive and longer clips.

audio.* uses the software layer to play the audio and it has a notable lag on Android. media.* writes directly to the hardware bypassing the standards layer. [import]uid: 199310 topic_id: 33649 reply_id: 135322[/import]

Thank you for the reply. I have seen this issue in old posts but since my project ran fine (my s1 still does) until the current public build I thought this was a new issue.

Are there plans to address this issue in the future? Surely fixing this should be a priority. I like corona and wouldn’t want it to be looked down upon over this problem. Or perhaps plans to disable using the new audio api and go back to the one in the previous public build?

I will try using the media API and see how it goes for now. [import]uid: 92709 topic_id: 33649 reply_id: 135326[/import]

The engineers are very aware of this problem. But if I understand what the engineers have posted on in the past, its more of the interaction of the audio layer in the OS and the hardware where the problem lies and not something we can easily get at.
[import]uid: 199310 topic_id: 33649 reply_id: 135329[/import]

I have always found android with corona to have terrible audio lag. Its always been this way, really disappointing. Doubt this will change anytime soon, so I’ll be looking at another SDK besides corona for future apps [import]uid: 19620 topic_id: 33649 reply_id: 135295[/import]

It shouldn’t be necessary switch. Any audio lag in the past wasn’t noticeable. It’s only because of this change that tried to improve the audio. Now it’s crazy. I’m disappointed that there hasn’t been any response to this from the developers. Audio sync is a priority issue.

Interestingly, this lag doesn’t happen on My Galaxy S 2.3.3. [import]uid: 92709 topic_id: 33649 reply_id: 135303[/import]

I have always had problems with Audio lag on Android using the Audio.* API. However I have the opposite experience with the latest builds. For me the lag issue in the Audio API has been vastly improved.

I have a Galaxy S (1st gen) and a Google Nexus as test devices for Android.

With the new release there is still a lag though, and I would estimate that to about 150-200ms as you’ve also done, but previously it was closer to 800ms when using the Audio API.
I use the Media.* API for short sound effects to reduce this lag, however the lag is still around 100ms.
The recommendation from CoronaLabs is still to use the Media API for short sounds on Android.

My understanding is that Corona Labs have done as much as they can to minimize this lag. Whatever lag that’s left is the different implementations of Android done by the device manufacturers.

[import]uid: 70847 topic_id: 33649 reply_id: 135305[/import]

Yeah, my first generation Galaxy S is fine. I just wish could revert to using the old audio api, that’s all. It worked on both my devices. I’ll have to try the media API I guess. This issue is amazing and if it is such a problem using another development API shouldn’t help right?

I just don’t get how it worked fine for me before but is now broken… [import]uid: 92709 topic_id: 33649 reply_id: 135309[/import]

This question gets asked a lot, and I think the current recommendation is for time sensitive, short clips, to use the media.* library on Android only and use audio.* on iOS and on Android for non-time sensitive and longer clips.

audio.* uses the software layer to play the audio and it has a notable lag on Android. media.* writes directly to the hardware bypassing the standards layer. [import]uid: 199310 topic_id: 33649 reply_id: 135322[/import]

Thank you for the reply. I have seen this issue in old posts but since my project ran fine (my s1 still does) until the current public build I thought this was a new issue.

Are there plans to address this issue in the future? Surely fixing this should be a priority. I like corona and wouldn’t want it to be looked down upon over this problem. Or perhaps plans to disable using the new audio api and go back to the one in the previous public build?

I will try using the media API and see how it goes for now. [import]uid: 92709 topic_id: 33649 reply_id: 135326[/import]

The engineers are very aware of this problem. But if I understand what the engineers have posted on in the past, its more of the interaction of the audio layer in the OS and the hardware where the problem lies and not something we can easily get at.
[import]uid: 199310 topic_id: 33649 reply_id: 135329[/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]