Image and Audio losing sync

Hi - I've got a problem when playing a "cut scene" that I've written.

There's 1 MP3 (low quality - 64k, to keep file size low), which plays for about 30 seconds.

On top of this, I have a number of 'scenes' - each typically showing a transparent PNG image on top of another background image (PNG or JPG). I've tried to scale down the images as much as possible to reduce file size.

The images are displayed with display.newImage and a few neat transitions. Each 'shot' of the scene is within its own function, and they all call each other in a set sequence. The net result: a short 'cut-scene' where various things appear / happen in sync with the MP3 file.

This works fine on my MacBook. But when I build it, and run on my iPad, the images begin to delay / each function starts slightly later, and are therefore losing sync.

Any ideas why this is? Am I going to have to worry about performance of all different devices and the effect it is going to have on this audio / visual syncing?

Apologies in advance if I haven't explained this very well!


How are you playing the audio? Using openAL, You can pre-cache the entire file (takes memory) but will provide you less sync problems.



I'm using audio.loadSound (as opposed to loadStream) for that very reason.

Another point, I use a global varaible for each image (e.g. FOREGROUND01 = display.newImage(" 001F.PNG ")). I reference this in the function required (as opposed to specifying them all upfront).

As I switch to another function, I tidy up by using 'FOREGROUND01:removeSelf() FOREGROUND01 = nil' to free up memory and remove the image from the screen, and also then perform garbage collection.

If I use local variables, I have no way of referencing the image once in another function, and the image remains onscreen.

Any thoughts are gladly appreciated.

views:1467 update:2011/11/14 9:16:56
corona forums © 2003-2011