Fmod pause

I would like to ask people here using fmod. When the player enters the pause menu I would like to pause all playing sfx’s and the bgm. What is your approach to this? I have tried to read the fmod forum / documentation but, as always, it is very hard for me… of course this is a fault of mine.

Many thanks!

Ciao!

I can tell you what we do in interrogation. Fair note: This was a long time ago and I didn’t do most of the sound design so I may be remembering wrong:

  1. For SFX, we just fade their volume down using automation and forget about them. I think they’re assigned to a mixer bus or a VCA from the mixer window and we fade that down using automation and a global parameter.

  2. For music, we keep a reference to the event and when the pause happens, we:

  • Duplicate the event instance (parameters and playhead) as best as we can, but don’t start the new one just yet.
  • Stop the event. Music events have automation set up on them so that they stop with a fade out (I don’t exactly remember how to do that). There’s a flag you can give to event_instance:stop() so that it waits for automation to finish instead of abruptly interrupting it.
  • When the user unpauses, we make the copy start playing again, from exactly the place where the previous one left off, but set the volume to 0 and fade it in (again, using automation set up in FMOD Studio on the event’s volume)
2 Likes

@dapetcu21 THANKS! Your solutions are really clever!

And your approach for bgm is perfect also for my game. On the other hand, being the game mostly an action game, I think it is important to pause and resume the sfx’s. Also, some sfx are looped.

Your implementation make me think that pausing / resuming may be hard with fmod, indeed you are not using them. I will see what I am able to do and, if it has any general audience interest, I will post it here!

1 Like

I only did that with the music so that the music is always stnced with the game timer.

But you can call :set_paused() on any event instance if you don’t mind an abrupt pause.

If you want fading you could fade doen the entire SFX VCA, and only then call :set_paused(), but there will be a delay between pausing the game and the sfx pausing.

1 Like

@dapetcu21 Thanks again (and again…)!

But I have to call :set_paused() on any playing sfx’s? So I have to keep track of the playing ones and use some callback to be notified when an sfx finish playing? At the moment I am only starting them and forgetting at all. Or maybe it is possible to call set_paused() on a bus? or any other king of grouping of events…

1 Like

I remember searching for this and didn’t find any grouping. The main issue with keeping track of events is that completion callbacks aren’t implemented yet, so you don’t know when to clear out the event instance from your table. I guess you could poll their playing state each frame though.

1 Like