Hi, i’m wondering if I can solve this within our FMOD session or if we have to do this through code.
Currently in game we use mostly parameters to change sections of music and swapping environments to switch between different pieces. What we’re trying to figure out, is how we could have area music and boss music in the same event, use a parameter to switch to the boss section, then once it’s dead, go back to the same timeline position in the area music.
I did some reading around and am wondering if we’d have to gettimelinesposition before the parameter change, then settimelineposition afterwards. But then I’m not sure if that would work with music outro’s without some delays in triggering those from the code, and whether that would work with smooth fades that you get from regular parameter changes & transition regions.
We can do this with swapping environments right now, but it can get a bit messy getting that implemented properly with things changing often during development, so we’re trying to see if we can find a way that we can deal with it on our end.
Also, does the music follow the AHDSR rules when pausing & unpausing with setPaused(true) or (false)? This is for us trying to also have some form of dynamic stingers when encountering certain important things in areas, where it could fade out the current music, play the stinger, then fade back in to where it left off.
Going back to the same exact same position isn’t really possible purely through Studio; getting the timeline position and using it to go back to that position later will get you close, but it’s not perfect.
Is there any particular reason that you want to put multiple different music tracks in the same event, instead of keeping them in separate? I ask because doing so generally requires more work and resources than keeping them separate; whereas it’s easy to simply pause one event and play another.
Does it have to be the exact same position? Presumably there’s some reason why you don’t want to restart the paused music from the beginning, but would it be acceptable to restart from a random point in that track, or from a specific point in its middle section?
No. As of the time of writing (October of 2023), neither pausing nor unpausing an event triggers an AHDSR modulator’s attack or release period, though a small volume ramp is automatically applied to the signal when pausing or unpausing in order to prevent pops.
Honestly, it’s mostly because that’s just how we’ve always done it when there’s a boss in the same area/zone. So that’s why I’ve been trying to see if we can figure out how to get this to work without us having to go back and change all the older events and get someone to program in environment switches. But I was kind of coming to the conclusion that it would most likely be required after reading everything I could find on FMOD forums.
Well at first I was trying to find if we could do the random start point as that was a simpler fix I thought. So no, it doesn’t necessarily have to be the exact position, just not always the start if you somehow keep retriggering the other music by running in and out of areas that would change the parameters.
Did I read somewhere that you could fake the AHDSR somehow when pausing?
In that case, there’s a number of ways to get the behavior you want. The simplest would be to add a random modulator to the “start offset” property of an instrument, but you could also create a set of transition markers to different destination markers at the start of your event, and assign them probability trigger conditions so that which one is triggered is randomized each time your event starts.
Not while pausing, but you could potentially fake pausing by using gettimeline position before stopping the event, and use set timeline position to put it back at the same place when startign the event.
Thanks for all the help, I think we may just have to change how we trigger some things and use separate events.
Another question though. We’re thinking of adding some musical stings in to accent some events during gameplay and want to have the music come back to where it was. We’re already able to do this with how we switch environments in game, but I’m wondering if just how FMOD is receiving parameters from the game to trigger things in FMOD, whether there is information I can send from FMOD that the game can pick up to trigger things on that end. Specifically so I can have a trigger at the end of the stinger so the game knows when to go back to the other piece of music.
The FMOD Engine is mostly built on the idea that your game handles all of its own state and internal logic, and so only needs to sends information to the FMOD Engine, not receive it back… But there are a few exceptions to that.
You’re probably most interested in FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER, a callback that can be fired when the timeline playback position of an event instance passes a destination marker. By putting such markers in the same events as your stingers at the end of the stingers’ instruments and using this callback, your game’s code will be able to know when a stinger ends.