Half a second lag on all sound/music

Hi guys,

Im starting to really pull my hair out over this issue. All my sound effects that play after collision have a huge lag until played. I have done loads of research and understand that this use to be an issue pre Android 4.1 but I am using 4.3 on an HTC One and I am still getting this huge delay. I have tried using .wav and .mp3 files and the same thing is happening. I am not doing anything special, just loading them using, placing them in a function and then activating on collision. Because the lag is so similar across the board and is so large it has to be down to something I’m doing wrong? It cant be down to something like bit rate/mono sound surely? I have used audacity to make sure all the sounds are mono anyway but to no avail. Did anyone else have this issue which they sorted.

local sndCoin2 = audio.loadSound("audio/coina.wav") local function playCoinSound() audio.play(sndCoin2) end function monkeyCollision (self, event) if event.phase =="began" then if event.target.name == "coin" and event.other.name == "hero" then playCoinSound() etc...

Troubling that the lag is happening on a 4.3 device.  Did you try using the old audio API to see if that improves things?  

media.playEventSound()

i did some testing on a nexus 7 (2012) circa 4.1 and found that it had a definite “preference” for 44.1k audio. that is, i thought i was doing it a favor by only using 22k audio (and of course making sure everything matched up), but i was able to noticeably reduce lag *at least on that specific device* by going back to the originals and exporting as 44.1k, pcm signed, 16b, mono, wav. it was non-intuitive, and my only guess was that 44.1k might be specifically optimized in some way. measured via hi-speed camera method (time from visual indicator to onset of audio event), i was getting ~300ms lag, reduced to ~80ms. fwiw

What format are your sounds in?  I would try 11khz mono sounds myself and see if that changes anything.  Make sure there is no dead air at the beginning.

Troubling that the lag is happening on a 4.3 device.  Did you try using the old audio API to see if that improves things?  

media.playEventSound()

i did some testing on a nexus 7 (2012) circa 4.1 and found that it had a definite “preference” for 44.1k audio. that is, i thought i was doing it a favor by only using 22k audio (and of course making sure everything matched up), but i was able to noticeably reduce lag *at least on that specific device* by going back to the originals and exporting as 44.1k, pcm signed, 16b, mono, wav. it was non-intuitive, and my only guess was that 44.1k might be specifically optimized in some way. measured via hi-speed camera method (time from visual indicator to onset of audio event), i was getting ~300ms lag, reduced to ~80ms. fwiw

What format are your sounds in?  I would try 11khz mono sounds myself and see if that changes anything.  Make sure there is no dead air at the beginning.