Dont continue until Sound has stopped

Hello,
I have a problem with the VO of a game I have been doing. I want to program it so the event its called and played once. After this, the code continues to happen. A example would be -“Oh, the elevator is coming”- And then load a new level. I could workaround with a routine that changes the map after X seconds (VO line duration) but it seems too complex.

What I mean is, I’m trying to do a function, loop or coroutine that waits until the sound has finished (FMOD_PLAYBACKSTATE_STOPPED) to continue, for example, to change the map without cutting VO lines.
I have tried with a while(!sound.FMOD_PLAYBACKSTATE_STOPPED) and it went infinite. I don’t know how to proceed on this one.

That sounds like a reasonable way of timing Events, if the Event is never getting into the Stopped state then there may be a bigger issue here.

By attaching the Studio Profiler and recording a session, you will be able to see if events are being cleaned up and released when they should be, or if they are building up for some reason.

What version of FMOD are you using?
We released a fix in 1.10.11 for an issue that was not cleaning up instances when they were supposed to, although I’m not sure if this is related.

I am using an older version than 1.10.11
Is it too complex to upgrade FMOD without errors? Im trying to upgrade it to the latest 1.10 version but the DLLs cant be replaced.
As you said, the while loop works until something happens with the stop state. If somethng go wrong, i get struck in an infinite.
I am thinking in geting the audios length and using that value in a coroutine that waits certain time to continue. I will update if that works :smiley:

We have documented this on our website: https://fmod.com/resources/documentation-unity?version=2.0&page=troubleshooting.html#copying-files-failed-during-import-of-unitypackage-file

This is caused by the libs being loaded when the Editor is loaded, so currently the libs need to be deleted while the Editor is closed. Then you can import the new package without any issue.

If that doesn’t fix the stop state issue, it would be interesting to see a Profiler capture of what exactly is going on.

1 Like

I managed to update FMOD finally without any problems. But the question is still on, how could I implement that VO system, apart from using playback state?

You can use EventInstance::setCallback to receive a callback when the EventInstance has stopped:
FMOD_STUDIO_EVENT_CALLBACK_TYPE.