How to know if a sound is really played

Hi there.

In my game I have several characters with voices, I want voices to don’t overlap, so in fmod studio I created groups ( bus ) , put all my voices in this group set max instances to 1 and set stealing : None for this group.

This works fine. But now I want the character to show a bubble if he talks, so I need a callback from fmod to know if that character has talked.
I get stick there, I tried to use EventInstance::setCallback :

  • with a lambda ( to get reference to my Character instance inside of my callback function ) but this crash.
  • with a static callback function , in addition to EventInstance::setUserData, but I’m stick to using properly IntPtr to point to my Character instance.

I also tried to get informatiosn about the bus so I can know how many instances it gets ( via RuntimeManager.GetBus ) but we don’t have enough details about bus in the api… ( nothin about instance count … )

Do you have any advice in how to implement this ? Thx.

You should be able to use callbacks to be notified when an event occurs, see the Programmer sound example which makes use of FMOD.Studio.EVENT_CALLBACK_TYPE.