Sounds are loading late on phone

Hello everybody !

I feel a soft sound offbeat when I build my app.on my phone. It doesn’t occurs when I’m on simulator.

Perhaps my code is bad ?

Here :

function scene:addScore()

    self.score = self.score + 1

    audio.play(‘file.wav’)

    self:updateScoreText()

end

To put it a bit clearer, I have to push out of the screen some enemies that coming from the skies.

This function is called in a Runtime Event (“enterFrame”) which is checking everytime if an enemy is enough for to remove him and then append the score and play the sound.

It works fine on simulator but the sound takes about 0,7 seconds to load on my Samsung S4 Galaxy - Android 4.4.2

and that’s a little frustrating.

Thank you and forgive my bad english. ~

Android has always has lagging issues with using OpenAL for sound. It’s been made better in later versions of Android, but 4.4 is around the time they addressed it so you may still be seeing the problems. Even the fixed version can lag under some circumstances.

If sound need to be played in a timely fashion consider using event.sound instead of the audio.* calls. It can’t mix sounds and there is no in-game audio control, but they are played pretty quickly.

Rob

I see, it doesn’t matter. I was just curious if my own code was in cause or not.

However, I fear misunderstand, to toggle this event.sound, doesn’t that mean that I’ve to produce a sound beforehand with audio.play ?

Thank you very much.

Remi

No, you can use event.sound() in much the same way as you do audio.play(). event.sound() has some limitations but it plays in a timely manner on older Android devices.

Rob

Hi,

I apologize but I e event.sBound() without success. Besides, I don’t know how to introduce the path of my sound :p 

I consulted the documentation about it : https://docs.coronalabs.com/api/event/notification/sound.html

But it couldn’t be helped.

Here’s my code and my differents attempts :

local function greenCollision(self, event)

–event.sound = “sounds/enemy_hurt.wav”

–event.sound(“sounds/enemy_hurt.wav”)

–event.sound()

end

Thank you very much for your precious help !

Android has always has lagging issues with using OpenAL for sound. It’s been made better in later versions of Android, but 4.4 is around the time they addressed it so you may still be seeing the problems. Even the fixed version can lag under some circumstances.

If sound need to be played in a timely fashion consider using event.sound instead of the audio.* calls. It can’t mix sounds and there is no in-game audio control, but they are played pretty quickly.

Rob

I see, it doesn’t matter. I was just curious if my own code was in cause or not.

However, I fear misunderstand, to toggle this event.sound, doesn’t that mean that I’ve to produce a sound beforehand with audio.play ?

Thank you very much.

Remi

No, you can use event.sound() in much the same way as you do audio.play(). event.sound() has some limitations but it plays in a timely manner on older Android devices.

Rob

Hi,

I apologize but I e event.sBound() without success. Besides, I don’t know how to introduce the path of my sound :p 

I consulted the documentation about it : https://docs.coronalabs.com/api/event/notification/sound.html

But it couldn’t be helped.

Here’s my code and my differents attempts :

local function greenCollision(self, event)

–event.sound = “sounds/enemy_hurt.wav”

–event.sound(“sounds/enemy_hurt.wav”)

–event.sound()

end

Thank you very much for your precious help !