# When i resume FMOD Studio instance from pause, song position shift a little bit

**URL:** <https://qa.fmod.com/t/when-i-resume-fmod-studio-instance-from-pause-song-position-shift-a-little-bit/22586>\
**Category:** FMOD Engine\
**Tags:** cpp\
**Created:** [February 9, 2025, 6:07pm UTC](https://qa.fmod.com/t/when-i-resume-fmod-studio-instance-from-pause-song-position-shift-a-little-bit/22586 "2025-02-09T18:07:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pyr0Guy](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@Pyr0Guy](https://qa.fmod.com/u/Pyr0Guy)\
**Post date:** [February 9, 2025, 6:07pm UTC](https://qa.fmod.com/t/when-i-resume-fmod-studio-instance-from-pause-song-position-shift-a-little-bit/22586/1 "2025-02-09T18:07:36Z")

</div>

I’m using FMOD Studio with banks and as a raw file in my project, and I’ve encountered an issue when pausing and resuming audio. I load my audio as a bank event (i.e., an FMOD Studio Event Instance) and use the setPaused(true) method to pause the audio. However, while the audio is paused, the event’s internal timeline continues advancing. This means that when I unpause the event, the playback position jumps ahead (e.g., from 100 ms to 150 ms), even though the audio was supposed to be paused.

![CHARTER-9001_SSMBavjunx](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/6/6acb84f19d948d406b4e194ef34218585487e902.gif)

When i use raw file (like wav or ogg) everything is fine.

Audio.cpp

```auto
unsigned int Audio::GetSongPosition(const std::string& songName)
{
	unsigned int pos;

	if (auto* channel = ResourceManager::GetChannel(songName))
		ERRCHECK(channel->getPosition(&pos, FMOD_TIMEUNIT_MS));
	else if (auto* instance = ResourceManager::GetEventInstance(songName))
	{
		int tmpPos;
		ERRCHECK(instance->getTimelinePosition(&tmpPos));
		pos = static_cast<unsigned int>(tmpPos);
	}
	else
	{
		std::cout << "There is no: " << songName << std::endl;
		return 0;
	}

	return pos;
}

```

---

<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:** [February 10, 2025, 1:45am UTC](https://qa.fmod.com/t/when-i-resume-fmod-studio-instance-from-pause-song-position-shift-a-little-bit/22586/2 "2025-02-10T01:45:20Z")

</div>

Hi,

Thank you for the explanation and the code. Could I please grab the FMOD version you are using?

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/8/8a0753bf9f77abefccd98178362c443d52016688.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/2/295fd7dc9cf516bf8c1fe6ef41804fca7e01a731.png)

---

<div class="post-metadata">

**Author:** ![Pyr0Guy](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@Pyr0Guy](https://qa.fmod.com/u/Pyr0Guy)\
**Post date:** [February 10, 2025, 3:44pm UTC](https://qa.fmod.com/t/when-i-resume-fmod-studio-instance-from-pause-song-position-shift-a-little-bit/22586/3 "2025-02-10T15:44:02Z")

</div>

Hello

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

Here is my FMOD Studio version

---

<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:** [February 11, 2025, 12:39am UTC](https://qa.fmod.com/t/when-i-resume-fmod-studio-instance-from-pause-song-position-shift-a-little-bit/22586/4 "2025-02-11T00:39:52Z")

</div>

Thank you for the information.

I have been able to reproduce the behavior. It is possible to get the sound’s channel from the event instance to get a more accurate position.

> **Example function**
>
> ```c++
> // Example use:
> FMOD::ChannelGroup* cg = nullptr;
> ERRCHECK(instance->getChannelGroup(&cg));
> 
> chan = FindSoundChannel(cg);
> //
> 
> FMOD::Channel* FindSoundChannel(FMOD::ChannelGroup* channelGroup)
> {
> FMOD::Channel* chan = nullptr;
> FMOD::Sound* sound = nullptr;
> 
> int numChannels = 0;
> if (channelGroup->getNumChannels(&numChannels) == FMOD_OK && numChannels > 0)
> {
> if (numChannels > 1)
> {
> return chan;
> }
> else
> {
> if (channelGroup->getChannel(0, &chan) == FMOD_OK)
> {
> if (chan->getCurrentSound(&sound) != FMOD_OK)
> {
> chan = nullptr;
> return chan;
> }
> else
> {
> return chan;
> }
> }
> }
> }
> 
> int numGroups = 0;
> if (channelGroup->getNumGroups(&numGroups) == FMOD_OK && numGroups > 0)
> {
> if (numGroups > 1)
> {
> return chan;
> }
> else
> {
> FMOD::ChannelGroup* child = nullptr;
> if (channelGroup->getGroup(0, &child) == FMOD_OK)
> {
> chan = FindSoundChannel(child);
> }
> }
> }
> }
> 
> ```

However, I will pass on this issue to our development team to investigate further. Thank you for bringing this to our attention.

---

<div class="post-metadata">

**Author:** ![Pyr0Guy](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@Pyr0Guy](https://qa.fmod.com/u/Pyr0Guy)\
**Post date:** [February 11, 2025, 2:06am UTC](https://qa.fmod.com/t/when-i-resume-fmod-studio-instance-from-pause-song-position-shift-a-little-bit/22586/5 "2025-02-11T02:06:25Z")

</div>

Okay, thanks for help

---

<div class="post-metadata">

**Author:** ![Pyr0Guy](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@Pyr0Guy](https://qa.fmod.com/u/Pyr0Guy)\
**Post date:** [February 12, 2025, 3:24pm UTC](https://qa.fmod.com/t/when-i-resume-fmod-studio-instance-from-pause-song-position-shift-a-little-bit/22586/6 "2025-02-12T15:24:40Z")

</div>

Hello again, the code that im using now still makes that jumps at a pause

Here the GetSongPos function

```auto
unsigned int Audio::GetSongPosition(const std::string& songName)
{
	unsigned int pos;

	if (auto* channel = ResourceManager::GetChannel(songName))
		ERRCHECK(channel->getPosition(&pos, FMOD_TIMEUNIT_MS));
	else if (auto* instance = ResourceManager::GetEventInstance(songName))
	{
		FMOD::ChannelGroup* cg = nullptr;
		ERRCHECK(instance->getChannelGroup(&cg));

		FMOD::Channel* chan = FindSoundChannel(cg);
		ERRCHECK(chan->getPosition(&pos, FMOD_TIMEUNIT_MS));
	}
	else
	{
		std::cout << "There is no: " << songName << std::endl;
		return 0;
	}

	return pos;
}

```

And a little re-writen but still the same FindSoundChannel function

```auto
FMOD::Channel* Audio::FindSoundChannel(FMOD::ChannelGroup* channelGroup)
{
	if (!channelGroup)
	{
		return nullptr;
	}

	FMOD::Channel* chan = nullptr;
	FMOD::Sound* sound = nullptr;

	int numChannels = 0;
	if (channelGroup->getNumChannels(&numChannels) == FMOD_OK && numChannels > 0)
	{
		for (int i = 0; i < numChannels; ++i)
		{
			if (channelGroup->getChannel(i, &chan) == FMOD_OK)
			{
				if (chan->getCurrentSound(&sound) == FMOD_OK && sound)
				{
					return chan;
				}
			}
		}
	}

	int numGroups = 0;
	if (channelGroup->getNumGroups(&numGroups) == FMOD_OK && numGroups > 0)
	{
		for (int i = 0; i < numGroups; ++i)
		{
			FMOD::ChannelGroup* child = nullptr;
			if (channelGroup->getGroup(i, &child) == FMOD_OK && child)
			{
				chan = FindSoundChannel(child);
				if (chan)
				{
					return chan;
				}
			}
		}
	}

	return nullptr;
}

```

---

<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:** [February 13, 2025, 2:30am UTC](https://qa.fmod.com/t/when-i-resume-fmod-studio-instance-from-pause-song-position-shift-a-little-bit/22586/7 "2025-02-13T02:30:35Z")

</div>

Thank you for the code.

Can you try using [FMOD Engine | Core API Reference - ChannelControl:setPaused](https://fmod.com/docs/2.02/api/core-api-channelcontrol.html#channelcontrol_setpaused) rather than pausing the event instance?

A detailed explanation of the the delay is present can be found here: [Best way to pause/unpause while keeping sync - #5 by Leah\_FMOD](https://qa.fmod.com/t/best-way-to-pause-unpause-while-keeping-sync/22354/5)

---

<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:** [February 17, 2025, 3:55am UTC](https://qa.fmod.com/t/when-i-resume-fmod-studio-instance-from-pause-song-position-shift-a-little-bit/22586/9 "2025-02-17T03:55:14Z")

</div>

For the audio asset could you please try toggling the `Loading` mode ([FMOD Studio | Managing Assets - Loading Modes](https://fmod.com/docs/2.02/studio/managing-assets.html#loading-modes)):

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

This will help to reduce the `jump` noticed when resuming the event. Another option may be setting the event macro `Priority` to `Highest` ([FMOD Studio | Event Macros Drawer - Priority](https://fmod.com/docs/2.02/studio/event-macro-controls-reference.html#priority)) which can also reduce some drift caused by the virtualization system. I will note this has been solved in `2.03`.

Hope this helps.
