Is there a way to get the playback time of a song more accurately and faster than GetTimelinePosition()?
Hi,
If you retrieve an event instance’s underlying channel group, you can do a couple of things:
- Get the value of the channel group’s underlying DSP clock. 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 of the event’s channel group. You can get a child channel with
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
1 Like
Do you have example code?
Sure thing:
// 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);
}