Keyoff() Unity Function Not Playing Event correctly

Hi all! Long time lurker first time poster here.

I am building a game in Unity and just recently updated both my FMOD studio and FMOD studio Unity integration version from 2.0 to 2.02.15.

In my game I am using the keyOff function in a Unity monobehavior ( formerly triggerCue() ) to advance a tutorial narration in my game incrementally. I set sustain points, have a couple of transitions controlled by params to control what is played at specific times.

When using FMOD 2.0 and the triggerCue() function, the sustain points and transitions worked perfectly. Whenever triggerCue() was run, the audio in that event played until it reached a sustain marker, as intended.

However since upgrading, my event does not play correctly. Specifically, I have some audio that plays when my scene begins which leads to a single sustain marker. After keyOff is run in my game, the audio then plays until it hits a bit of a Transition Junction, where if a specific param (AirPods) has a value of 1, the audio jumps to a specific region, and if the param (AirPods) has a value of 0 it goes somewhere else.

When keyOff is used, audio always pauses correctly at the first sustain marker, however when it gets to the "Transition Junction” BOTH lines from opposite areas in the event play at the same time. So for example if the AirPods param value is 0, the audio that is supposed to play is heard, along with the audio that would play if the value was 1. They both play at the same time.

Additionally, one of two sounds heard follow the correct sustain points and pauses correctly, while the other sound playing at the same time advances through the event without stopping or pausing at all. So there is a lot of overlap.

The ONLY change in my code is the updated function, replacing the depreciated triggerCue() with keyOff(). This code works perfectly in FMOD version 2.0 with the triggerCue().

I’ve tried reinstalling FMOD, updating Unity and even tried a few “pseudo tricks”, like adding a loop region of silence in FMOD studio in hopes it would stop one of the two double audio portions being played. But nothing I do seems to work.

The Unity function that controls this is a button. When pressed the following function is run:

public void GamelevelCue() {

			gamelevel.keyOff();
		
	} 

Below is a screenshot of my FMOD studio event with the sustain points and transitions:

I made a backup of my game before I updated FMOD and tested the same code and studio project using FMOD 2.0 and triggerCue() and it works correctly. So it seems to be an issue with either keyOff(), FMOD 2.02.15, or an error within my FMOD project.

To try to fix this I’ve tried:

  • Restarting Unity
  • Restarting FMOD
  • Removing and Reinstalling FMOD 2.02.15 (Studio and Unity integration)
  • Rebuilding the event that’s having trouble

I would truly appreciate any help or suggestions on how I can get this to work again!

Thanks!

Thanks for such detailed information! However, given the complexity of your event behavior, it’s a little difficult for me to see whether I’m replicating the logic that is causing the issue. If possible, can I get you to upload your FMOD Studio project (or a stripped down version containing just the problematic event) to the “Uploads” tab of your FMOD User Profile so that I can take a closer look?

Also, just to clarify - are you experiencing this issue in both FMOD Studio and Unity? Or only in Unity?

Hi Louis,

Thank you for the response!

I’m attempting to add the studio project to uploads, but I’m seeing a message that says I need to register my project, but then get a pop up saying that I don’t need to register my project. No matter what I choose it won’t let me upload.

With that in mind, this is only happening within Unity. The project does play, pause at sustain markers and jumps to transitions correctly in FMOD studio. I’ve tried rebuilding the events and still seeing this issue within Unity.

Is there another way I can share this project with you?

Thanks!

That’s definitely a little strange. I’ll get someone to take a look and see whether they can figure out what’s happening with your project registration.

Since it is only happening in Unity, I’d be remiss not to ask: is it possible there may accidentally be two instances of the event playing at once?

Alright, give registering and uploading a shot now.

Hi Louis,

Thanks for checking!

When I first noticed this issue I also thought that there could be two instances running at once, but after the last couple of days searching, I can confirm that only one instance is playing. With that in mind, in the event two instances are playing, both would still stop at sustain markers correct? When the two streams are playing, one follows the correct sustain markers and one continues playing the event, bypassing all loops, sustain markers and transitions.

UPDATE:
Actually I was just able to replicate this in FMOD studio as well…which now leads me to believe that this is an issue within the project….but I’m not seeing where.

Hi Again Louis,

Just tried again and still not able to upload my project. Now I get a “Pending approval” message. Thanks again for all you help!

The expected behavior is that both instances obey all logic and still stop at sustain markers, unless you’ve queued up sustain key offs by calling keyOff() multiple times on one of the event instances. The fact that you’re observing the instance bypassing other event logic is definitely strange.

You should be able to upload now. If you could also upload your Unity project, or a stripped down version of it where you can still reproduce the issue consistently, that would be great.

Hi Again Louis,

I’m still seeing following messages while trying to upload the project and my project status is still pending approval:

With that said, I am able to replicate this in my FMOD studio project. I can visually see that the playhead does stop at the sustain marker, but I can also see the levels in the mixer on that track and hear the sounds of a region playing…despite the fact that the playhead is not moving.

Thanks again!

There appears to be a small issue on our backend; give it another try now.

Do you have any other instrument on the various parameter sheets that your event has that are playing independently of the timeline, and therefore aren’t being affected by the sustain point?

Hi Louis,

Great I’ve just uploaded it!

To answer your question, no I’m not seeing any other region or instrument playing at the same time. What’s interesting is that track 1 still shows audio levels in the mixer, even once the playhead is paused and not moving.

Once you open the project you can replicate this issue at the sustain marker at 29 seconds. Key off from that point and let it stop at the next marker. You’ll notice that audio will continue playing, even when the playheads stops.

Thanks again!

Thanks for uploading your project, and apologies for the hassle.

I can see exactly what you’re describing - this bug appears to be caused by having a sustain point extremely close to the end of a synchronous instrument that is using a streaming asset. I’ve passed this along to the development team for further investigation, but as a workaround, if you move the sustain point to the end of or after the instrument, or shorten the instrument so that it ends at the sustain point, then the instrument should correctly stop playing.

1 Like

Hi Louis,

THANK YOU! Nudging those markers did the trick!

I would have NEVER thought about that. I truly appreciate the explanation and all of the help! Now off to find fix the next bug in my list (Luckily not FMOD related!).

Thanks again!

1 Like