Performance question: fire multiple instances of an event, or having it constantly running?

I have a question as to what is better, performance-wise, for an event (or if it doesn’t matter either way and to implement things the way we find easiest for our project). The event in question involves repeating a sound a lot, but also varying at specific moments (think something like footsteps which may constantly be sounding, but need to change based on speed, surface type, etc.) Is it better to:

1.) Start the over and over again every the sound needs to play.

2.) Keep the event constantly playing, but use parameters to have it move to a silent state when not needed, and then move to the sound when it is needed.

Thanks for the help!

Hi Thomas,

Performance in this sense is a trade off between CPU usage and memory usage, and will largely depend on what your resource budget is.

Keeping one event instance constantly playing will have the sample data (unless the sample data is streaming) hanging around in memory but will load slightly quicker, whereas creating and releasing a new instance each time it is required requires slightly more CPU usage but has the benefit of cleaning up after itself.

A more effective look into having a well optimized system will be to make good use of the virtual voice system and event stealing. This is a large topic in itself so I would recommend reading our documentation:

https://www.fmod.com/resources/documentation-api?page=content/generated/overview/virtualvoices.html#/

https://www.fmod.com/resources/documentation-studio?page=advanced-topics.html#stealing-and-virtualization

Thanks,
Richard

1 Like