Say I have an event that’s environmental ambience (wind, thunder, birdsong) with 16 layered tracks. I have parameters setup to raise gain on some tracks as-needed, so they’re essentially fading in from silence.
Part of the purpose of this is allowing flexibility in a “unified” event while having a big-picture view (so I don’t have to jump between editing different events). Say I play an instance of this event that doesn’t need birdsong, so those tracks are silenced.
When those tracks are silent, is there any way to “unload” them so they’re not using memory or counting as active voices? Even if there’s some clever workaround to do this, I’m curious.
Yes and no. There’s no way to manually unload one specific track of an event at runtime, but FMOD already does most of what you’re asking for automatically.
When the volume of a channel (i.e.: a playing instance of an instrument) drops below a certain threshold (defined by the vol0virtualvol value set in FMOD_ADVANCEDSETTINGS by your game’s code), that channel is virtualized. Virtualized channels are not included in any submixes, and so require much less CPU when compared to active channels, and do not consume voices.
Virtualized channels do, however, still consume memory. This is because they need to keep the asset associated with the instrument loaded into memory (unless it’s a stream, of course), so that in the event that the channel’s volume increases again, it can resume playing the asset as if it had been playing silently the whole time.
@joseph Always great to get your help! Also to clarify, if a vol0virtualvol is not specified, what is the default? E.g., if I add a Gain effect to a track and set that to ∞ , will that track of an event be virtualized without needing to set FMOD_ADVANCEDSETTINGS ? Is there a best practice for setting this if using Unity-FMOD integration?
No. As I mentioned above, a channel is generally a playing instance of an instrument.
For example, if an event instance contains an asynchronous single instrument, each time that instrument is triggered is one channel. Thus, if a loop region causes the instrument to be triggered three times, it’ll use three different channels; if the second and third times the instrument is triggered happen before the first time has finished playing out, then all three channels will exist at once; and if there are two instances of the event, and each of them is playing three instances of that instrument, then they’ll use a total of six channels.
You are correct that only the effects on the one track with active channels will consume CPU. If all the channels routed into a track are virtualized, the effects on that track are automatically set to idle mode, in which they do not consume any CPU.