Delay between sounds and screen updates

Hi,

I want to play a series of sounds when the user touches something on the screen and at the same time also update the screen.

I want the screen update to happen before i play the sound, but even if i call the sound function after the screen update , in the simulator i see the sound being played first blocking all screen updates.

  1. what is the best practice around loading sounds and updating screen elements at the same time?
  2. how does one provide a delay between two sounds being played?
  3. does preloading all sounds at startup help? or should each screen only load the sounds it requires. In my tests, i did not experience much difference.
    4)How does one cleanup the sound variables ?

thanks [import]uid: 55009 topic_id: 11777 reply_id: 311777[/import]

  1. It depends on your app.
    audio.loadSound() preloads files into memory so they start instantaneously when you play them, at the trade off of using RAM and needing to wait for the file to load.
    audio.loadStream() loads only small chunks at a time with the trade off of more latency when you start playing and other tradeoffs (documented elsewhere).

  2. use timer.performWithDelay

  3. See (1)

  4. audio.dispose()
    [import]uid: 7563 topic_id: 11777 reply_id: 42979[/import]

Thanks. I am using media.newEventSound and playEventSound instead of audio functions since my sounds are short words or letters.

even if use something like this where i have to play two sounds one after the other, it seems the two are playing almost in parallel even with the timer delay in place.

[lua]timer.performWithDelay(5000,playstockSentence(),1)
timer.performWithDelay(10000,playWord(selWord),1)[/lua] [import]uid: 55009 topic_id: 11777 reply_id: 42996[/import]

Those sound functions are semi-deprecated. Don’t use them unless you absolutely have to. We only keep them around because of Android nonsense.

As for your callbacks, you are using them wrong. See this thread:
http://developer.anscamobile.com/forum/2011/06/22/timerperformwithdelay-bug

[import]uid: 7563 topic_id: 11777 reply_id: 43088[/import]