Current Track Duration or End Callback in Multi-Instrument VO Event

Hi everyone,

I’m working on a project using Unity and FMOD that supports multiple languages and includes nearly 100 games with VO events. Each VO event contains multiple tracks configured using Multi-Instrument modules. We are using a manual localization method: inside each VO event, we’ve added two tracks (e.g., ENG and TUR), and we use a continuous parameter to control which one is actually playing via volume automation.

I’ve previously read that FMOD’s built-in localization system doesn’t work well when localization is handled via labeled parameters and Multi-Instrument setups like this (Localized VO System).

Here’s the issue:

When trying to get the actual duration of the currently playing sound inside an EventInstance, FMOD seems to return the total duration of the event or the entire Multi-Instrument group — not just the currently audible segment. Moreover, the stopped callback is only triggered once the entire track ends, not the individual playing instrument.

To work around this, after starting the event I wait a few frames, then use getChannelGroup() to inspect the sub groups. I check which one has volume > 0 to detect the currently playing track, and then I try to retrieve the playing sound and get its duration via Sound.getLength.

This works in some cases, but when localization tracks are set up using Multi-Instruments, it still returns the full track length rather than the specific playing variation.

So my question is:
Is there a reliable way to get the duration of only the currently playing instrument inside a Multi-Instrument setup — or at least receive a callback when only that instrument finishes playing, not the full group?

Any tips or alternative approaches would be much appreciated!

Thanks in advance.

1 Like

Hi,

Event instances allow you to set a callback that are fired at a number of key moments. For your purposes, FMOD_STUDIO_EVENT_CALLBACK_SOUND_PLAYED will allow you to access the underlying sound that is about to be played by the event. FMOD_STUDIO_EVENT_CALLBACK_SOUND_STOPPED does the same, but is fired when the sound stops being played. You can then use any of the Sound functions to get any info about the sound that you need e.g. Sound::getLength, Sound::getName, etc.

Since you’re working with C#, if you want to pass that info in and out of the callback, you’ll need to pin some kind of variable/struct/class in memory and pass it to the event as user data to be retrieved in the callback so you can set that data. Take a look at how this is handled in our Unity Timeline Callbacks example for an example of how to do so.

We had difficulty reliably retrieving the duration of only the currently playing track in VO events using Multi-Instrument with multiple tracks. Since the Localization parameter mutes all but one track, we used the SOUND_PLAYED callback to inspect the name of the played Sound, filtered it based on the active locale, and retrieved the duration only if it matched. This approach allowed us to accurately get the duration of the correct track in Multi-Instrument setups.