Hi there,
I was wondering what’s the best way to handle the playing flow of an event.
I have a script with an event that is played when an action is done (ex: my character saying things when looking at some objects) and i didn’t understand when is right to release the instance or not.
I was thinking of three possible implementations:

  • start and release an event after the sound is finisced and then Initialize (instance.getEvent()) the event, so that it’s ready to start again. This solution seems the best to me in terms of performance, but i don’t really like to create instances of event cause in case of bugs I can have multiple instances of that event that i cannot handle anymore.
  • Use setPause() to stop and start the sound, but i don’t know how is this solution in terms of performance.
  • Use a loop region of silence in fmod studio and a parameter to let the flow exit from that loop region, but in this case the event will be always active and it seems a bad thing to do in terms of performance.

As always thank for your knowledge and support,

  • You must to post comments
Best Answer

Hi there,

I think your first option is the best. Just create and release a fresh event instance each time you want to play. If you are worried about having multiple instances running, you can limit this via the Polyphony setting in Studio. It’s under the Event Macros tab.

As an alternative, you could keep the one instance around and just call start() and stop() as you need. This is also quite efficient.

  • Simone Pellegrini

    Thank you for your answer, I really appreciate to discuss about this topic with someone.
    The possibility to limit event instance is something i didn’t know, but it doesn’t seem to be a good choice because it’s true that i won’t have multiple irreferenced instance of the same event, but i have the problem that often I call release and the event is released after a while( the sound must end before the event is released), so i couldn’t call getEvent right after I call release. Also i can have an event that is associated to N gameObject and i can’t limit event instances from fmod (for example if I have to manage footsteps of every character in the scene).

    Moreover i can’t use the stop function arbitrary, cause i have to manage event loop cycle. In fact I want that the cycle is finished before stopping the event and this is why I prefer to use release. Using release I can set the parameter to let the sound exit the loop and then it will be automatically stopped (and released).
    Of course I can easily workaround this problem checking the sound event from unity and releasing it when it’s outside of the loop, but I don’t like to use the update method for this purpouse and it also seems really expensive when you have a lot of sounds in the scene.

    Thank you for your time and your efforts

  • Graeme Webb

    Okay, sounds like your first option is the way to go. Create a fresh instance via FMOD_StudioSystem.GetEvent(), set parameters, then call start() and release() when you want to play.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.