Syncing Animation and Sound

Started by Cogliostro, Sun 29/03/2015 22:14:03

Previous topic - Next topic

Cogliostro


Okay, I have a LONG animation sequence, 85 frames long, with a delay of 5.  I'm trying to sync the audio file I created for the animation.  And when I say SYNC I really mean it.  (i.e. Mechanical humming starts from the first frame, amps up at frame 50, and continues to frame 425.  Metal banging begins at frame 290 and completes at frame 380.  You get the idea.)

I'm running into trouble.  I have a total of 425 frames.  I *assumed* 40 frames per second, for a animation length of 10.625 seconds, however, it turns out to be closer to 16 seconds, and I'm hoping someone can tell me the ratio of frame/delay to seconds.

- Cogliostro
"First things first, but not necessarily in that order." - Dr. Who

Snarky

#1
425 frames / 16 secs = 26.6 frames/sec.

What's the problem, exactly?

Oh, I get it. You're saying that you have 85 frames in your animation, and with a delay of 5 that should be equivalent to 425, and at 40 cycles/sec that should run about 10 seconds, but it's not.

Well, it doesn't quite work like that. Even with a delay of 0, the animation still takes some time to play. I think the way it works is that at 0 it plays one frame/cycle, and then the delay is the number of additional cycles to hold the same frame beyond that. So 85 frames with a delay of 5 should take 85*6 = 510 game cycles to run, and at 40 cycles/sec that should take 12.75 seconds. Not sure where the additional delay is coming from.

Cogliostro

Under "Show Preview" I couldn't set it to a delay of zero, so I had assumed it wasn't possible.  Okay, I timed FIVE runs of the animation to get some passable accuracy = 75 frames with a delay of 5 = 14.2 seconds for the total animation or 0.1893 seconds per frame.

Nothing I do ties this back to 40 frames per second, but this should be close enough for comedic timing.

Thanks,
Cogliostro
"First things first, but not necessarily in that order." - Dr. Who

selmiak

Hmmm, I'd rather time the animation right with less delay. Try some values between 0 and 5 if 5 is too slow and see when it looks right ingame. And fiddle with the sound afterwards to make it fit to the animation and not fit the animation to the prerecorded sound.

Snarky

I'm pretty sure the preview timing doesn't exactly match the in-game timing. I wouldn't rely on it, but always test in-game.

There are two factors to look into here:

1. The number of game cycles/frame.
2. The number of game cycles/sec.

As discussed, the first number is not simply the delay. (It is also affected by any frame speed settings, so you might want to check that they are all set to the default.) It should be pretty simple to check by creating a game cycle counter that you increment in repeatedly_execute_always(), and comparing its value before and after you run the animation.

There are various reasons why the second number might not be exactly 40, even if that's what you've set the game speed to. Most notably, the speed might dip for a cycle here and there if you're doing anything CPU-intensive, and the engine doesn't try to "catch up" after that happens.

Monsieur OUXX

#5
It's pretty hazardous to hope that an animation will be sync'ed with a sound, even in professional game engines.

The good practices would be :
1) To keep the sounds in the animation separate and play them only when you've reached the corresponding frame.
OR
2) To create a video with sound and play it.

A dirty workaround would be to use the Seek function to force-position the sound file at the right place when the corresponding frame is reached on screen, but as you can imagine that would make the sound stutter.

Apart from that, you can only double-check your game cycles per frame and seconds (as Snarky explained) and hope for the best. Everything can be ruined on a slow computer where the sound takes too many a few milliseconds to be loaded and starts paying delayed.


 

HandsFree

You are aware you can just link a soundfile to a frame in the editor? It's not a solution for increasing the volume, but it probably is for starting the metal banging.

SMF spam blocked by CleanTalk