Any way to save on resources by "unloading" tracks in an event?

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.

1 Like

@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?

If vol0virtualvol is not specified, it defaults to 0. The API uses a scale of 0-1 for volume, so a volume of zero in code corresponds to a volume of -oo dB in FMOD Studio.

Zero’s a good value for it to be at, since it means channels must be completely inaudible to be virtualized by this setting.

Incidentally, you can find the default values of various FMOD settings in our documentation.

It’s enabled by default, so you shouldn’t have to do anything special to get the behavior that’s best for most game projects.

1 Like

@joseph I appreciate the clarity! Makes sense. Thanks again… as always.

@joseph Another fine clarification for this: does channel = track here?

For example:

  • Say I have an FMOD event with 12 audio tracks “playing”. All of them also have effects chains.
  • 11 of those tracks are currently silent at -∞ gain.
  • Therefore, can I expect that all 12 tracks will consume memory, but only the 1 that’s actually heard will be using CPU on the audio playback and effects?

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.

1 Like

I missed that distinction the first time, and your example helped me visualize it. Thanks again!