Currently, I am using FMOD with UNITY.
Let’s say I have 50 AI characters around the map. Each of them will do a random activity that requires a 3D sound to be played correctly. However, since the AIs are spreading across the map, player should hear the sounds which are close enough only.
I know that FMOD has attenuation feature so I can adjust max distance of the sound. If the listener (player) is out of the range, no sound can be heard.
My question is what will be best in term of performance?
(1) Let AI characters create sound EventInstances, start() them normally, let FMOD be the one to handle the attenuation distance and hope that FMOD will be able to take care all of these with a good performance.
(2) Manually manage this by adding a Collision Sphere to a player that detects surrounding AIs within the attenuation distance, the AIs will play sounds only if they are within the Sphere. However, by doing this it means that I have to keep track of the activity process and need to start or resume sound at a correct timing.
Or if you think there is any better way to handle this case, please feel free to suggest me here. Thank you.
FMOD already takes care of this for you. You don’t have to develop your own system for it.
The FMOD Engine automatically determines when a channel (a track or bus) has become inaudible due to volume attenuation, and “virtualizes” it. Virtualized channels do not play or process their audio content, and so event instances with virtualized channels consume only the infinitesimal amount of resources required to update their timeline and parameter values. If a virtualized channel’s volume increases enough for it to theoretically become audible again, FMOD automatically makes it real (non-virtual) once more - with the result that the event instance resumes playing with its current timeline and parameter values, creating the illusion that the instance continued playing while out of earshot.
If you’re still concerned about resources, you can use FMOD’s built-in event instance stealing behaviors to customize how your game culls excess event instances by setting the max instances and stealing behavior properties of events and buses.
You can read more about instances limiting, stealing, and virtualization in the Stealing and Virtualization section of the Advanced Topics chapter of the FMOD Studio User Manual, and more about stealing in the