How and when to call studio.system.update

Hi there. I’m just wondering how and when I should be calling the studio.system.update function? I think it may help an issue that I’ve got with a game I’ve been working. I have not used any of the studio.system functions before and just wondering if any one could break it right down for me… All the way down.

There is a section on Update in the Getting Started section of the White Papers.

FMOD should be ticked once per game update. When using FMOD Studio, call Studio::System::update, which internally will also update the Core system. If using Core directly, instead call System::update.

If FMOD Studio is running in asynchronous mode (the default, unless FMOD_STUDIO_INIT_SYNCHRONOUS_UPDATE has been specified), then the Studio::System::update will be extremely quick as it is merely swapping a buffer for the asynchronous execution of that frame’s commands.

const dt = 0.0;

let mut t = 0.0;
let mut current_time = std::time::Instant::now();
let mut accumulator = 0.0;

let mut prev: State = State::new();
let mut curr: State = State::new();

loop {
    let new_time = std::time::Instant::now();
    let mut frame_time = new_time.from(current_time).as_nanos / 1000000000; // from ns to s
    if frame_time > 0.25 { // where did this constant come from?
        frame_time = 0.25;
    }
    current_time = new_time;

    accumulator += frame__time;

    while accumulator >= dt {
        prev = curr;
        update(curr, t, dt);
        accumulator -= dt;
        t += dt;
    }

    let alpha = accumulator / dt;
    let state: State = curr * alpha + prev * (1.0 - alpha);

    render(state); // render state should match physics state
}

But what if your gameupdate runs at a fixed rate(for deterministic physics, etc)? e.g sim at 30 fps while your rendering runs at 60-whatever monitor refresh rate? Do you still call studio.system.update in the fixed game update? Or do you move it out to where the render() is called?

I doubt it would make any obvious difference in either case. I think it makes more sense to call it during the game update instead of the rendering update, just to keep FMOD’s state in sync with your game’s state as much as possible.