What is the best way to handle instances

In our games, we are keeping track of the instance and create them on demand and never destroy them.
When a sound needs to be played we search for an instance, if an instance exists and is not playing (FMOD_STUDIO_PLAYBACK_PLAYING) or is not starting (FMOD_STUDIO_PLAYBACK_STARTING) we use this instance and call start() on it. If none are found we create a new one.

This used to work perfectly until the recent update 1.04. With this recent update we are encountering issues were sounds do not play anymore after reaching the max voices (with voice stealing enabled) because they never seem to end. They also do not end because the sounds are not using the timeline. The sound module (blue bar) is on parameter, not sure why the musician did it but it seemed he did it to have better control over the sound. Moving the sound on the timeline fixes the issue. Does having the sound module (blue bar) on the parameter and not on the timeline creating a side effect?

This also made me wonder, do we have to release the instances when they are stopped and create a new one, or can we reuse previously played ones. First option would be worse since we would have to ping all instances every frame to see if they are still playing.

I’m the audio person working with Moleki on this. So, semi unrelated but worth mentioning I think:

One of the reason I refrain from using the timeline for some sound effects is that I use multisound on different audio track, with randomised pitch only for some tracks.
If I were to use the timeline, then the waveform of the sounds would appear in the sound module, but would not be affected by its random pitch, thus creating unwanted repetitions of parts of the wavfiles.

To understand what I mean, here’s a screenshot of one sound event in our game, which is an arrow hitting a canon (you wanna play that game already, I know it :).
track Audio 1 : a multisound containing randomised impact sounds (arrow against a generic surface)
track Audio 2 : a metallic impact sound re-used from another event but at a higher, randomised pitch (we’re tight on memory)

This is done with no sound module on the timeline, but simply on the Parameter1 tab. However, for the purpose of this example, since apparently using the timeline could potentially solve our instances issues mentioned above by Moleki, I moved my sound modules to the timeline and created a pitch enveloppe to better show the problem (but I’m just using a pitch modulator in reality) :


You can see the red enveloppe representing pitch, and the waveform just above it. But with the pitch going up, in reality the waveform has already finished playing when the cursor reaches about one third of the sound module, and since the sound module doesn’t stop there, Fmod keeps repeating playing the sound, creating an unwanted loop effect. I could shorten the length of the sound module by hand but:

  1. It’s tedious since I have no visual aid showing where the waveform will end exactly with once affected by the modified pitch
  2. since in my real case use I’m not using an enveloppe but a random modulator on the pitch, the length of the sound module would need to be different each time the sound is played, so it solves nothing.

I’d appreciate if someone could let me know if I’m approaching this the right way or not. Thanks!

In cases like this, we recommend not using a timelocked sound module. Create a multi sound module on the timeline, and place your audio file in its playlist; With default settings the sound will play to its end and then stop, regardless of whether the end of the waveform coincides with the timeline cursor leaving the trigger region. (Of course, you may want to work outside of the timeline for other reasons; The decision is entirely up to you.)

We do plan to improve the way waveforms on timelocked sound modules are displayed to take into account various forms of pitch alteration, but it’s taking us some time. Thank you for bearing with us in the mean time.

And regarding the question above, any best practice advice? Thanks

Thanks for your answer.

Please let us know also if not using the timeline is causing our bugs, and if we should “port” or existing non-timeline events to timeline ones (I have many many to do and it’ll be very tedious, so if there’s a way I can avoid doing that, I’m grateful, haha).