Download

Sync Audio and Video

Hey guys!

I’m trying to match the movement of a camera to the BPM of a song. I’m using a “Pawn” with “Add Movement Input” on every Tick to move my Camera 1 unit every frame.

The problem is that if I click on another UE4 window (to disable momentarily the renderer) the audio still continues and goes out of sync.

Is there a way I could make sure that both stays linked?

I guess the audio and video renderer are on different threads, which makes me think that If I drop some frame rendering out my visual, the audio would become of sync. Am I wrong?

Thanks!

Video demonstrating my problem :

Yes. The audio does run on a different thread with a much higher stable frame rate (probably 48khz rather than 60-120hz game frame rate). Anything you do will always be approximate as the game frame rate is unstable - especially when game frames are dropped during housekeeping tasks. The best you can probably do is keeping an approximate audio clock in the game thread using delta time - one beat being 0.5 seconds (120bpm) - incrementing the counter each time 0.5s is reached - and using that to determine which game frame you do something. That should keep you roughly in sync.