Hi everyone:
I am using FMOD to develop my action game.
My game characters will use the same action to wield different weapons, and these weapons will have their own sound effects.
These weapons will have many sound effects, and they have the same effector.
Now I have two solutions to design my sound effect implementation
1: I create an event for each sound effect, and trigger the corresponding event when the corresponding weapon is used.
2: I create an event that contains all sound effects, and play the corresponding sound effect through parameters. Trigger the event and set the parameters when the corresponding weapon is used.
I want to know which method will have better performance and which method is more reasonable.
This is less of a question of performance, and more of a question of how you prefer to implement your event structure and interact with it via the API/Unity integration.
In terms of the implementation, option 1 is generally more idiomatic to the idea of one-shot audio SFX, but may require a little more code to implement since you’d potentially need to manage the lifespan of each event (i.e. creation, starting, releasing). Option 2 abstracts some of the API usage away to design-time in Studio, potentially making it easier to interact with for non-coders, but also comes with caveats such as increased complexity when wanting to trigger specific SFX rapidly, which would require you to change the paramater value from and then back to the intended value.
As far as performance goes, CPU performance should be roughly the same. Memory usage has the potential to have slightly more notable differences depending on the context: option 2 contains all SFX at once, meaning the event metadata (and all sample data, if it hasn’t already been loaded for the entire bank) will be loaded at once, but if all option 1 SFX events exist at the same time, they’d in theory take up slightly more memory due to the additional audio tracks/ChannelGroups from each instance.
That said, I would recommend against prematurely optimizing - if you do run into any issues with performance, you should connect to your project via Live Update and use the Profiler to record gameplay and identify whether/where there are any issues.
Thanks for your answer.
This makes me more clear about some of the logic of Fmod in operation.
I will try to understand Event as a kind of SFX package, and make SFX that need to be used together into the same Event, such as the voice of an enemy and its own SFX.
There is really no need to optimize performance too early. Your explanation is very helpful for me to design the SFX structure in my project.