Update speed problem depending on buffer size

Hello, I am developing a rhythm game using fmod. I am calculating the current playing time of music with the code below, but I changed the buffer size in RuntimeManager.cs.
After debugging, it seems that the higher the buffer size is set, the slower the update speed of getDSPClock becomes. Is there any way to solve this?

void SetTime()
 {
     // get existing event instance's underlying ChannelGroup
     AudioManager.instance.eventInstance.getChannelGroup(out FMOD.ChannelGroup cg);

     // get ChannelGroup's DSP clock
     cg.getDSPClock(out ulong dspclock, out ulong parentclock);

     if (firstClock == 0)
     {
         firstClock = dspclock;
     }
	// 0.000020833333333f == 1 / 48000;
     time = (((double)dspclock - (double)firstClock) * 0.000020833333333f * 1000f) - musicOffset;
 }
1 Like

Hi,

What version of the FMOD integration are you using? Can I see the whole script you are using to calculate this?

1 Like

Thank you for answer. The version used is 2.02.21. I can’t upload the full code, but what I want to know is whether the update rate varies depending on the buffer size, and if there is another way to get the song’s playback time.

I think you can use the FMOD system time:

Get a more accurate time source with System.getSystemTime().
Implement a high-precision timer for more accurate synchronisation.

1 Like

Thank you for answer.
System.getSystemTime() function not found in fmod. Do you have example code?

Thank you for answer. The version used is 2.02.21. I can’t upload the full code, but what I want to know is whether the update rate varies depending on the buffer size, and if there is another way to get the song’s playback time.

Thank you for answer. The version used is 2.02.21. I can’t upload the full code, but what I want to know is whether the update rate varies depending on the buffer size, and if there is another way to get the song’s playback time.

Hi,

Apologies for the delayed response.

Unfortunately, I was unable to reproduce the issue. However, it would make sense that increasing the buffer size would affect the getDSPClock(). An alternative option may be using Channel::getPosition() this 'Retrieves the current playback position. You can retrieve the Channel from the ChannelGroup using ChannelGroup::getChannel(). You may have to dig down through a few channelgroup’s before you can find the right channel.

Hope this helps!