# Total Channel Count Grows Forever

**URL:** https://qa.fmod.com/t/total-channel-count-grows-forever/22288
**Category:** Unity
**Tags:** unity
**Created:** [November 12, 2024, 3:08am UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288 "2024-11-12T03:08:28Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Janooba](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/janooba/32/7348_2.png) [@Janooba](https://qa.fmod.com/u/Janooba)
#### Post date: [November 12, 2024, 3:08am UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288/1 "2024-11-12T03:08:28Z")

</div>

Hey there. I’m having an issue with audio cutting out “randomly” as I play, and profiling/debug shows that my total channel count grows until it reaches the set limit, then things start cutting out.

The odd thing is that I am most definitely releasing my instances after stopping them, but they just seem to go virtual and never actually clean up, even when loading into a new scene (after making sure to release instances on destroy).

The return result of my stop() and release() calls are “OK” as well.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/9/9a40844dcf201821227a8e266a4dab8ea8cf7f5c.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/4b4390ea504c90ef220eebbfabe672f21b16c9b3.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/2/2b00197e8a2d72b9ad3b920a687de30d67d312a4.png)

Any help would be appreciated, I feel like I missed something obvious here…

---

<div class="post-metadata">

### Author: ![Janooba](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/janooba/32/7348_2.png) [@Janooba](https://qa.fmod.com/u/Janooba)
#### Post date: [November 12, 2024, 3:33am UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288/2 "2024-11-12T03:33:01Z")

</div>

Figures I’d start finding what’s wrong as soon as I post here, but I’m still not sure on the proper way to do this.

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

The issue was that the events use a sustain point to play a start and stop sound for the event, but when you press stop, the timeline never actually stops. I assume I’m just not doing this “the right way” so what _would_ the right way to wrap a loop with a start and stop one-shot be?

---

<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: [November 12, 2024, 10:57pm UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288/3 "2024-11-12T22:57:11Z")

</div>

Hi,

Thank you for the screenshots and the information.

Could I grab the exact integration version you are using?

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/0/016fd77a00ccb800d14e2a07996673e7410be636.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/4c4f2f7ed9b8388a789da469590d8734e87f8965.png)

> [@Janooba](#):
>
> I assume I’m just not doing this “the right way” so what _would_ the right way to wrap a loop with a start and stop one-shot be?

Could you elaborate on the expected behaviour for the event?

Thanks for the info

---

<div class="post-metadata">

### Author: ![Janooba](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/janooba/32/7348_2.png) [@Janooba](https://qa.fmod.com/u/Janooba)
#### Post date: [November 13, 2024, 3:35am UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288/4 "2024-11-13T03:35:32Z")

</div>

Hey Conner, sure thing.

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

I honestly expected the timeline to automatically go from “stopping” to “stopped” after the playhead had moved off of the last clip in the timeline.

But overall, the event is supposed to encompass a car’s engine. So when you press play, it plays a one-shot of the cars starter turning over, then the main idle/rpm loop takes over. This can be controlled through parameters to change RPM and load on/off etc. Once the engine is stopped it would “stop” the event, which causes the idle/rpm loop to stop, and the “engine off” sound to play so that it sounds like it’s sputtering out.

---

<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: [November 15, 2024, 12:17am UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288/5 "2024-11-15T00:17:12Z")

</div>

Thank you for the explanation.

Unfortunately, I cannot reproduce the issue.

I think it may be solved by adding

```auto
var keyOffResult = _engineEventInstance.keyOff();

```

to your stop function to allow the event to fade out as expected.

However, I would prefer to test it with your project if that is possible?

---

<div class="post-metadata">

### Author: ![Janooba](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/janooba/32/7348_2.png) [@Janooba](https://qa.fmod.com/u/Janooba)
#### Post date: [November 15, 2024, 1:30am UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288/6 "2024-11-15T01:30:29Z")

</div>

Absolutely. I’ll do you one better and make a minimum repro project with just this case in it.  
I’m not sure where best to upload it, so I have it on my personal CDN here:  
[http://zipline.janooba.com/u/fmodRepro.zip](http://zipline.janooba.com/u/fmodRepro.zip)

All you need to do is:

1. Open `event:/Mercedes/Mercedes_Engine`
2. Press Play and let run for a few seconds
3. Press stop once and observe that the state does not go to “STOPPED”, but just continues playing the “Timeline” timeline until stop is pressed again.

Something about having another Parameter sheet in here seems to be what causes the issue.

Thank you for your time, it’s much appreciated!

---

<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: [November 15, 2024, 3:26am UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288/7 "2024-11-15T03:26:41Z")

</div>

Thank you very much for creating that so quickly! Would it be possible to upload the project to your profile here: [https://fmod.com/profile#uploads](https://fmod.com/profile#uploads).

---

<div class="post-metadata">

### Author: ![Janooba](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/janooba/32/7348_2.png) [@Janooba](https://qa.fmod.com/u/Janooba)
#### Post date: [November 15, 2024, 5:34am UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288/8 "2024-11-15T05:34:43Z")

</div>

For sure! It’s done now

---

<div class="post-metadata">

### Author: ![li\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/li_fmod/32/6577_2.png) [@li\_fmod](https://qa.fmod.com/u/li_fmod)
#### Post date: [November 19, 2024, 12:40am UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288/9 "2024-11-19T00:40:58Z")

</div>

Hi, since Connor is away, I will be continuing the investigation.

Thank you very much for uploading the project, that’s really helpful.

> [@Janooba](#):
>
> I honestly expected the timeline to automatically go from “stopping” to “stopped” after the playhead had moved off of the last clip in the timeline.

It looks like that the reason the event wasn’t stopped previously was because events with [logic marker](https://www.fmod.com/docs/2.02/studio/glossary.html#logic-marker) in the timeline logic track have [no natural end](https://www.fmod.com/docs/2.02/api/troubleshooting.html#audio-becomes-crackly-or-distorted-over-time), so they require manual stopping using [Studio::EventInstance::stop()](https://www.fmod.com/docs/2.02/api/studio-api-eventinstance.html#studio_eventinstance_stop).

Hope this helps, let me know if the issue persists

---

<div class="post-metadata">

### Author: ![Janooba](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/janooba/32/7348_2.png) [@Janooba](https://qa.fmod.com/u/Janooba)
#### Post date: [November 19, 2024, 3:00am UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288/10 "2024-11-19T03:00:17Z")

</div>

So then I would have to call stop twice it seems, once to trigger the stopping effect, then again to stop it completely later, does that sound correct?

---

<div class="post-metadata">

### Author: ![li\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/li_fmod/32/6577_2.png) [@li\_fmod](https://qa.fmod.com/u/li_fmod)
#### Post date: [November 19, 2024, 4:07am UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288/11 "2024-11-19T04:07:44Z")

</div>

Using the profiler, t have noticed that calling `stop` twice doesn’t fully terminate the event instance, leaving some resources active.

To address the issue, you could consider using a [Command Instrument](https://www.fmod.com/docs/2.02/studio/instrument-reference.html#command-instrument). Placing it at the end of the clip and set the command type to `Stop Event - Immediate`. This ensures the event stops completely when the timeline reaches the end of the clip.

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

---

<div class="post-metadata">

### Author: ![Janooba](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/janooba/32/7348_2.png) [@Janooba](https://qa.fmod.com/u/Janooba)
#### Post date: [November 19, 2024, 4:19am UTC](https://qa.fmod.com/t/total-channel-count-grows-forever/22288/12 "2024-11-19T04:19:08Z")

</div>

This solution should work! Thank you!
