# How to get an accurate timeline position

**URL:** <https://qa.fmod.com/t/how-to-get-an-accurate-timeline-position/22650>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [March 2, 2025, 10:13pm UTC](https://qa.fmod.com/t/how-to-get-an-accurate-timeline-position/22650 "2025-03-02T22:13:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RoboGooey](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@RoboGooey](https://qa.fmod.com/u/RoboGooey)\
**Post date:** [March 2, 2025, 10:13pm UTC](https://qa.fmod.com/t/how-to-get-an-accurate-timeline-position/22650/1 "2025-03-02T22:13:35Z")

</div>

Hello, I’ve been planning to work on a rhythm game that gives feedback to the player based on how early or late the button was pressed (perfect, great, etc…) alongside the number of ms the player was away from the desired time.

For that reason, I need to retrieve an accurate timeline position each frame. At first I tried using getTimelinePosition(), I’ve also tried to get the DSPClock from the event’s channel group.

```auto
private void Update()
{
    if (channelGroup.hasHandle()) {
        songInstance.getTimelinePosition(out int timelinePos);

        channelGroup.getDSPClock(out ulong DSPClock, out ulong parent);
        DSPClockPosition = DSPClock / (float)sampleRate * 1000;

        Debug.Log("Timeline: " + timelinePos + ", Clock: " + (int)DSPClockPosition);
    } else {
        songInstance.getChannelGroup(out channelGroup);
    }
}

```

I’ve seen that the default update rate is 20ms so I tried lowering it.  
The lowest interval of time I’ve gotten is 10ms, at 1ms update rate, 8 DSP buffer length, 4 DSP buffer count:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/f/f89f71faf87618e4d93cb211799508036501da4a.png)

Is there a way to improve this to get an updated time each frame?

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [March 3, 2025, 1:50am UTC](https://qa.fmod.com/t/how-to-get-an-accurate-timeline-position/22650/2 "2025-03-03T01:50:50Z")

</div>

Hi,

Thank you for the code and information.

Could I please grab your FMOD version? Disabling `Streaming` on the assets may improve timings: [FMOD Studio | Managing Assets - Loading Modes](https://fmod.com/docs/2.02/studio/managing-assets.html#loading-modes:~:text=for%20mobile%20platforms.-,Streaming,-%2D%20Assets%20are%20continuously).

Another option maybe:

> [@GetTimelinePosition accuracy for rhythm game](https://qa.fmod.com/t/gettimelineposition-accuracy-for-rhythm-game/20202/2):
>
> On the topic of more accurate timing information, you may 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.  
> [GetTimelinePosition accuracy for rhythm game - #2 by Leah\_FMOD](https://qa.fmod.com/t/gettimelineposition-accuracy-for-rhythm-game/20202/2)

---

<div class="post-metadata">

**Author:** ![RoboGooey](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@RoboGooey](https://qa.fmod.com/u/RoboGooey)\
**Post date:** [March 3, 2025, 12:26pm UTC](https://qa.fmod.com/t/how-to-get-an-accurate-timeline-position/22650/3 "2025-03-03T12:26:17Z")

</div>

Thanks for the quick reply, my FMOD version is 2.02.26.

I also tried to disable straming on the asset and it did not do any changes:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/f/f087e718960db6a8132b93a1831ef6bc0396acff.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/c/ca79ab4b651258e1d8f812102df5f07651f517cc.png)

About the timeline callbacks, I tried them and they can help me track the current beat but I dont know if the callback can help to get the time distance (early or late) from the input moment to a note, which can be on beat or off beat.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [March 10, 2025, 10:20pm UTC](https://qa.fmod.com/t/how-to-get-an-accurate-timeline-position/22650/4 "2025-03-10T22:20:35Z")

</div>

Thanks for testing that,

Tracking those off beat notes could be done using timeline markers:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/3/384ca851e362b6fac090d9b40ad6411c535d86b7.png)  
Which have their own callbacks [FMOD Engine | Studio API Reference - FMOD\_STUDIO\_EVENT\_CALLBACK\_TIMELINE\_MARKER](https://fmod.com/docs/2.02/api/studio-api-eventinstance.html#fmod_studio_event_callback_type:~:text=Parameters%20%3D%20FMOD_STUDIO_PLUGIN_INSTANCE_PROPERTIES.-,FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER,-Called%20when%20the). This will return the name of the marker as well:

```auto
struct Studio.TIMELINE_MARKER_PROPERTIES
{
  IntPtr name;
  int position;
}

```

Would this be able to cover those off beat notes?

---

<div class="post-metadata">

**Author:** ![RoboGooey](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@RoboGooey](https://qa.fmod.com/u/RoboGooey)\
**Post date:** [March 12, 2025, 12:43pm UTC](https://qa.fmod.com/t/how-to-get-an-accurate-timeline-position/22650/5 "2025-03-12T12:43:17Z")

</div>

Sorry for the confusion.

I understand that I can track predetermined timestamps using markers, but my issue is that I can’t capture the exact moment (in milliseconds) when a player makes an input. Since inputs are not predetermined and can happen at any frame, I need a way to track the time each frame accurately. Right now the value updates each 3 or 4 frames like i showed previously (due to the 10 ms interval). For reference, Unity’s AudioSettings.dspTime allowed me to track the exact time each frame.

---

<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:** [March 17, 2025, 6:46am UTC](https://qa.fmod.com/t/how-to-get-an-accurate-timeline-position/22650/6 "2025-03-17T06:46:51Z")

</div>

> [@RoboGooey](#):
>
> I need a way to track the time each frame accurately. Right now the value updates each 3 or 4 frames like i showed previously (due to the 10 ms interval). For reference, Unity’s AudioSettings.dspTime allowed me to track the exact time each frame.

Only seeing a 10ms interval despite setting the DSP buffer size to lower is likely a driver level issue. FMOD’s WASAPI output initializes in shared mode, which only allows for a minimum buffer size of 10ms (e.g. 480 samples at 48kHz) at the driver level - this would probably explain what you’re observing.

There unfortunately isn’t much way around this, beside using a different output driver that supports lower latency (e.g. ASIO) and seeing whether that provides you with the time resolution you need. You may need to modify the the initialization code in `RuntimeManage.cs` in order to override the output set in FMOD for Unity’s setting in the Unity Editor - the relevant lines of code in the latest version of FMOD for Unity can be found at:

- ~line 289 - the output type is retrieved from FMOD for Unity’s settings:

```CSharp
FMOD.OUTPUTTYPE outputType = currentPlatform.GetOutputType();

```

- ~ line 330: the core system is set to use the specified output

```CSharp
result = coreSystem.setOutput(outputType);

```
