Audio delay in Android

I just tested an Android build of my game Blocfall Free and found there are audio performance problems. A tap-triggered sound effect is delayed about half a second to a second, which isn’t acceptable.

Are there any audio performance tricks for Android builds?

This should work out of the box (and does for iOS):[/lua]
brickSound = audio.loadSound( “brick.wav” )

local playBrickSound = function()
audio.play( brickSound )
end

– when brick is touched playBrickSound[/lua] [import]uid: 1560 topic_id: 4779 reply_id: 304779[/import]

I’m having this issue also. There is a substantial sound delay on Android. [import]uid: 7079 topic_id: 4779 reply_id: 15400[/import]

I agree this is also happening to me on my Galaxy S - very fast phone, so it must be corona…

Also that is not the only object with a delay. Getting the GPS data takes FOREVER.

Viewing the Accelerometer sample, the screen refresh is very slow.

Whats going on with the android stuff corona?

[import]uid: 11860 topic_id: 4779 reply_id: 17655[/import]

Same here (Nexus 1) [import]uid: 30444 topic_id: 4779 reply_id: 21970[/import]

Same here with Nexus S. About 400ms since I push a button and a WAV file is played using audio.play().

Not sure how to get rid of it, if even possible.
[import]uid: 18260 topic_id: 4779 reply_id: 23891[/import]

Me to on HTC Desire, I have reverted back to media.playEventSound. Android support on a lot of issues is is very buggy with a when compared with corona on IOS. [import]uid: 11459 topic_id: 4779 reply_id: 24183[/import]

Same here, switched to playEvent and the latency went away. [import]uid: 18260 topic_id: 4779 reply_id: 24188[/import]

Hi,
We are aware of the latency issues when playing audio via the OpenAL-based APIs. As noted by @aguerrieri, the workaround until this is resolved it to use media.playEventSound() for low-latency playback.
Tim [import]uid: 8196 topic_id: 4779 reply_id: 24704[/import]

Personally i use media.playeventSound for all short event sounds, and preload them ALL at boot.

Then I use media.play for the main title background music - because its really odd if it doesnt start immediatly. Then I use audio.play for the game music, which loads after a small delay I have inserted on purpose. This then allows me to play other mix sounds on another channel on top if I need to. [import]uid: 8872 topic_id: 4779 reply_id: 25171[/import]

I get less of a delay using media.playEventSound() but there’s still a noticeable 400-500 millisecond delay between the touch event and the sound on my Nexus One. The delay is on each event, not just the first event. I’m using iTunes to convert to a 16bit 44k stereo wav because my attempts at using any other sound settings hasn’t worked.

local effect = media.newEventSound( ‘effect.wav’ )
local img = display.newImage( ‘myImage.png’ )

local function touchHandler( event )
if event.phase == ‘began’ then
media.playEventSound( effect )
end
end
img:addEventListener( ‘touch’, touchHandler )
[import]uid: 4596 topic_id: 4779 reply_id: 25341[/import]

Hello,

Does android support .MP3 file format ? [import]uid: 44599 topic_id: 4779 reply_id: 36434[/import]

+1 for no-latency playback ; ) [import]uid: 4596 topic_id: 4779 reply_id: 36597[/import]

Dear Ansca,

I believe this issue is still a major problem for many of us. Are there any updates on this matter? As the above posters have adequately mentioned, media.playEventSound() is highly buggy, and audio API is basically replacing it. It would be really helpful if we can have a bug and latency free audio playback.

Thanks! [import]uid: 108204 topic_id: 4779 reply_id: 76383[/import]

If I recall correctly, this is not a Corona problem.

The audio implementation in Android leaves much to be desired. Hopefully Google will be able to write a better implementation. I haven’t tried ICS (IceCreamSandwich) though. Hopefully it’s better. [import]uid: 70847 topic_id: 4779 reply_id: 76387[/import]

Everyone,

This is not a Corona issue. This is an Android OS issue that affects all Android developers. That is, all Android apps have this problem. Try running Angry Birds on a Kindle Fire and notice how bad the latency is.

Corona’s media APIs have less latency compared to our audio APIs because the Android APIs that we’re calling are known to have less latency, but also have far less audio options as well. Our audio APIs use OpenAL which provide more control over audio, but has more latency on Android. Unfortunately, we’re stuck with this behavior until Google addresses this issue themselves. Google did later create their own OpenSL library (their equivalent to OpenAL), but the latency issues were still not solved. [import]uid: 32256 topic_id: 4779 reply_id: 77153[/import]