# Get Playback Time

**URL:** <https://qa.fmod.com/t/get-playback-time/21010>\
**Category:** Unity\
**Created:** [December 20, 2023, 12:59am UTC](https://qa.fmod.com/t/get-playback-time/21010 "2023-12-20T00:59:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![guswnd332255](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@guswnd332255](https://qa.fmod.com/u/guswnd332255)\
**Post date:** [December 20, 2023, 12:59am UTC](https://qa.fmod.com/t/get-playback-time/21010/1 "2023-12-20T00:59:48Z")

</div>

Is there a way to get the playback time of a song more accurately and faster than 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:** [December 20, 2023, 4:09am UTC](https://qa.fmod.com/t/get-playback-time/21010/2 "2023-12-20T04:09:10Z")

</div>

Hi,

If you [retrieve an event instance’s underlying channel group](https://www.fmod.com/docs/2.02/api/studio-api-eventinstance.html#studio_eventinstance_getchannelgroup), you can do a couple of things:

- [Get the value of the channel group’s underlying DSP clock](https://www.fmod.com/docs/2.02/api/core-api-channelcontrol.html#channelcontrol_getdspclock). Note that this will only return the current time in samples, so you will need to compare it to a value retrieved earlier in time (i.e. when the event instance was started)
- [Get the playback position of a child channel](https://www.fmod.com/docs/2.02/api/core-api-channel.html#channel_getposition) of the event’s channel group. You can get a child channel with [`ChannelGroup.getChannel()`](https://www.fmod.com/docs/2.02/api/core-api-channelgroup.html#channelgroup_getchannel). Note that this is not the same as the playback position of the whole event unless the channels’ sound started playing, and has been playing, since the start of the event

---

<div class="post-metadata">

**Author:** ![guswnd332255](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@guswnd332255](https://qa.fmod.com/u/guswnd332255)\
**Post date:** [December 20, 2023, 4:30am UTC](https://qa.fmod.com/t/get-playback-time/21010/3 "2023-12-20T04:30:55Z")

</div>

Do you have example code?

---

<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:** [December 20, 2023, 10:16pm UTC](https://qa.fmod.com/t/get-playback-time/21010/4 "2023-12-20T22:16:24Z")

</div>

Sure thing:

```auto
// get existing event instance's underlying ChannelGroup
eventInstance.getChannelGroup(out FMOD.ChannelGroup cg);
// get ChannelGroup's DSP clock
cg.getDSPClock(out ulong dspclock, out ulong parentclock);

// iterate over all child Channels of ChannelGroup
cg.getNumChannels(out int numchannels);
for (int i = 0; i < numchannels; i++)
{
    cg.getChannel(i, out FMOD.Channel channel);
    // get position of current Channel
    channel.getPosition(out uint position, FMOD.TIMEUNIT.MS);
}

```
