# FMOD Delete channels after song is ended

**URL:** <https://qa.fmod.com/t/fmod-delete-channels-after-song-is-ended/22746>\
**Category:** FMOD Studio\
**Created:** [March 30, 2025, 12:38pm UTC](https://qa.fmod.com/t/fmod-delete-channels-after-song-is-ended/22746 "2025-03-30T12:38:46Z")\
**Posts on this page:** 6\
**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:** [March 30, 2025, 12:38pm UTC](https://qa.fmod.com/t/fmod-delete-channels-after-song-is-ended/22746/1 "2025-03-30T12:38:46Z")

</div>

So, basically, I created a tool that helps me place notes in songs for my game. When the song ends, FMOD deletes all its channels, and now I can’t scroll the song up/down, pause it, etc. I don’t have access to the FMOD Studio project—it’s on another person’s computer.

When I check the profiler, it’s clear that the channels are being deleted.

_Right before song end_

 ![NVIDIA_Overlay_kgDk6qTBNj](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/5/558759ae735739d376b5a09c03feac6930d6b9f2.png)

_After song ended_

 ![FMOD_Profiler_L3QEinEWK4](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/b/bad9d94dc7a9bc9133bdfb5b3286735297cdf8df.png)

Only the channel groups remain. What should I do? Is this happening because of the FMOD Studio setup or my code?

---

<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 30, 2025, 10:19pm UTC](https://qa.fmod.com/t/fmod-delete-channels-after-song-is-ended/22746/2 "2025-03-30T22:19:05Z")

</div>

Hi,

An option may be [FMOD Engine | Studio API Reference - Studio:: Bus::lockChannelGroup](https://fmod.com/docs/2.02/api/studio-api-bus.html#studio_bus_lockchannelgroup) which forces the FMOD system to keep a channel group avilable till `Studio:: Bus::unlockChannelGroup` is called.

Hope this helps!

---

<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:** [March 31, 2025, 2:29pm UTC](https://qa.fmod.com/t/fmod-delete-channels-after-song-is-ended/22746/3 "2025-03-31T14:29:14Z")

</div>

I tried to lock channel groups, but it seems I’m targeting the wrong bus. Here’s what I did:

```auto
FMOD::Studio::Bus* bus = nullptr;
ERRCHECK(fmodSys->getBus("bus:/", &bus));

if (bus)
	ERRCHECK(bus->lockChannelGroup());

```

But it doesn’t work. I wanted to lock the channel group for the main bus, but the API doesn’t provide a direct way to get the correct bus. Is there another approach?

---

<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:** [April 1, 2025, 3:00am UTC](https://qa.fmod.com/t/fmod-delete-channels-after-song-is-ended/22746/4 "2025-04-01T03:00:51Z")

</div>

> [@Pyr0Guy](#):
>
> But it doesn’t work

What are the errors that you are seeing? Would it be possible to share more code? Are you able to reproduce the issue in one of our example scripts: `"C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\examples\vs2019\examples.sln"`

> [@Pyr0Guy](#):
>
> API doesn’t provide a direct way to get the correct bus

You’re current method is correct for locking the master bus, if you call `fmodSys->flushCommands()` after locking the bus, it will ensure the channel group is created in the next update call.

If you want to lock all the buses you could use:

```C++
FMOD::Studio::Bus* bus[256];
int busCount;
masterBank->getBusList(bus, 256, &busCount);
for (int BusIdx = 0; BusIdx < busCount; ++BusIdx)
{
    bus[BusIdx]->lockChannelGroup();
    fmodSys->flushCommands();
}

```

Hope this helps!

---

<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:** [April 1, 2025, 3:58pm UTC](https://qa.fmod.com/t/fmod-delete-channels-after-song-is-ended/22746/5 "2025-04-01T15:58:35Z")

</div>

My code for creating and starting event is

```auto
FMOD::Studio::EventDescription* envDesc = nullptr;
std::string event = "event:/" + eventName;

ERRCHECK(fmodSys->getEvent(event.c_str(), &envDesc));

if (envDesc)
{
	FMOD::Studio::EventInstance* eventInstance = nullptr;

	ERRCHECK(envDesc->createInstance(&eventInstance));
	ERRCHECK(eventInstance->setCallback(nullptr));

	ERRCHECK(eventInstance->start());

	m_PauseVector.push_back(eventInstance);

	ResourceManager::LoadEventInstance(eventName, eventInstance);
}

```

Update

```auto
if (!m_PauseVector.empty())
{
	FMOD::Studio::EventInstance* instance = m_PauseVector.back();
	FMOD::Studio::EventDescription* envDesc = nullptr;

	if (instance->getDescription(&envDesc) == FMOD_OK && envDesc)
	{
		FMOD_STUDIO_LOADING_STATE state = FMOD_STUDIO_LOADING_STATE_ERROR;

		if (envDesc->getSampleLoadingState(&state) == FMOD_OK &&
			state == FMOD_STUDIO_LOADING_STATE_LOADED)
		{
			Audio::SetPosition(realName, 0);
			Audio::Pause(realName, true);

			m_PauseVector.pop_back();

		}
	}
}

```

So when i write

```auto
FMOD::Studio::Bus* bus = nullptr;
ERRCHECK(fmodSys->getBus("bus:/", &bus));

if (bus)
	ERRCHECK(bus->lockChannelGroup());

```

This code executes after the event is created but before it’s added to ResourceManager and m\_PauseVector. The bus pointer is returned without errors, but the channel group remains unlocked - after playback ends, the channels still get deleted.

---

<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:** [April 3, 2025, 10:40pm UTC](https://qa.fmod.com/t/fmod-delete-channels-after-song-is-ended/22746/6 "2025-04-03T22:40:02Z")

</div>

Thank you for the code and testing that. Maybe we could look into a different solution. Could you explain the desired behavior? What are you hoping to do with the channels once the event has finished playing? The more information the better. Thanks
