Are we supposed to have an emitter per event?

Hello !

I’m coming from Unity’s default sound system, and I used to just feed different audioclips to one audiosource, depending on the action the player did (jump, walk, push, etc.). The thing is you can’t easily do that with the default fmod studio emitter… You can of course create multiple emitters on the same gameobject, each one with its event, but I guess this is cumbersome if you have dozens of events. What if the prefered method for this ? Should I just script my own emitter from scratch, allowing me to switch events easily ? I can definitely do that, but looking at the emitter default script, it’s not a straightforward “event.Play()” thing, so I just wanted to know whether I had to delve further into the API to get this, or if there was some easier way.

Thank you !

You could create a single event which would play the desired sound in relation with a parameter value. Doesn’t it answer to your request?

The recommended method is to create one emitter each time you want to play an instance of an event. This method allows you to achieve polyphony, and the FMOD engine contains a variety of optimizations that assume this method.

You could make your own emitter that functions as you describe, but you’d be fighting against FMOD’s design in order to make your game’s sound consume more resources, and also limiting the number of sounds it can play at a time. We therefore don’t recommend it.

While this method would work (and would even work around the polyphony limitation of using one event instance), it would also increase the resource cost of the event.

Thanks a lot for the reply !

I’m a bit confused and just want to make sure I got it correctly : you mean that each time my player generates a sound, I should create a new Studio Event Emitter ? Via script ? Because I can’t find the API that allows me to easily do that, there is no constructor (as far as I can tell) on there ?

Also I thought each time an emitter was triggered with Play(), it created a new instance, allowing polyphony out of the box, but I guess I was wrong ?

Anyway thanks for the help :slight_smile:

Edit : just watching some more tutorials, some guys does that each time a step is made :

FMOD.Studio.EventInstance jl = FMODUnity.RuntimeManager.CreateInstance(stepPath)
FMODUnity.RuntimeManager.AttachInstanceToGameObject(jl, transform, GetComponent < RigidBody>());
jl.setParameterByName(parameterName, value);

There might by some typos here, and I guess attaching a sound step to the object doesn’t make much sense so I’d remove that, but is this what you meant ?

This is the usual way to do things, but as for whether you “should” do it, that depends on the needs of your project. Creating an emitter each time you need to play an instance allows you to take advantage of optimizations designed to reduce your project’s resource costs, and simplifies the achievement of polyphony; however, if your project does not need those benefits, it’s fine for you to take another approach.