# GetTimelinePosition accuracy for rhythm game

**URL:** <https://qa.fmod.com/t/gettimelineposition-accuracy-for-rhythm-game/20202>\
**Category:** Unity\
**Created:** [May 7, 2023, 10:24pm UTC](https://qa.fmod.com/t/gettimelineposition-accuracy-for-rhythm-game/20202 "2023-05-07T22:24:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fynthesizer](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/fynthesizer/32/4989_2.png) [@Fynthesizer](https://qa.fmod.com/u/Fynthesizer)\
**Post date:** [May 7, 2023, 10:24pm UTC](https://qa.fmod.com/t/gettimelineposition-accuracy-for-rhythm-game/20202/1 "2023-05-07T22:24:48Z")

</div>

Kia ora,

I’m trying to make a rhythm game in Unity using FMOD and I’m having trouble getting accurate timeline position info. At the moment I just have a simple system where when the player clicks it will log how many milliseconds early or late you were from the beat.

The number I’m getting back with getTimelinePosition() seems to consistently be ~150ms higher than expected, which isn’t ideal. Is there anything I might be doing wrong or some way I can get more accurate timing information?

```auto
// In the music manager class
public int GetTimelinePosition()
    {
        musicInstance.getTimelinePosition(out int position);
        return position;
    }

// In the player class
private void FirePressed(InputAction.CallbackContext obj)
    {
        print(MusicManager.instance.GetTimelinePosition());
    }

```

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [May 8, 2023, 12:56am UTC](https://qa.fmod.com/t/gettimelineposition-accuracy-for-rhythm-game/20202/2 "2023-05-08T00:56:51Z")

</div>

Hi,

Due to the nature of the FMOD system, i.e. commands are queued up and executed asynchronously when the system is updated, and the fact that Studio updates (by default) every 20ms, there will likely always be a very slight difference between the expected and actual timeline position; however, this is normally extremely small, and nowhere near 150ms.

You may wish to try using [ChannelControl::getDSPClock](https://www.fmod.com/docs/2.02/api/core-api-channelcontrol.html#channelcontrol_getdspclock) on an event’s underlying ChannelGroup to retrieve more accurate timing info. If the asset isn’t set to stream, and the difference from the DSP clock is similarly significant, could I get you to provide your Unity, FMOD Studio, and FMOD for Unity version numbers, and upload your FMOD Studio project to the uploads tab of your [FMOD Profile](https://www.fmod.com/profile) so I can try to reproduce the issue?

On the topic of more accurate timing information, you may also wish to look into using timeline callbacks - they allow you to define code yourself that is called by the FMOD System upon reaching certain points in the event timeline, such as markers or beats, which is typically good for rhythm games. If that sounds like something that would be useful, our Unity docs have a basic [timeline callbacks example script](https://www.fmod.com/docs/2.02/unity/examples-timeline-callbacks.html) that I would recommend taking a look at.
