# Slaving OpenSceneGraph to an external time base?

I'm working on an OpenSceneGraph animation, and I want events in the animation to be synchronized to a time reference provided by my audio player (BASS or FMod). Yes, this is a demo :) . Which time do I set, and where? Sync is more important than frame rate or continuity - if the audio rewinds, I want the visuals to rewind, too. (To support GNU Rocket.)

I have looked at the forum posts and Google results, but haven't seen a clear answer for this use case.

• FrameStamps have a frame number, a calendar time, a simulation time, and a reference time. I think the simulation time is what I should change - is that so?

• Is specifying a new simulation time as a parameter to frame() or advance() the right way to specify the time? Will that work even if time moves backwards?

## 1 Answer

The answer can be found in the osgViewer::ViewerBase class:

/** Render a complete new frame.
* Calls advance(), eventTraversal(), updateTraversal(), renderingTraversals(). */
virtual void frame(double simulationTime=USE_REFERENCE_TIME);

virtual void advance(double simulationTime=USE_REFERENCE_TIME) = 0;


So just pass the simulation time you want to viewer.frame(time).