Hey,
With sound objects in the engine, we can have up to 32 voices active at any given time, which allows us to have the same same sound playing multiple times without having to duplicate the object. This is really useful for emitters; an example being torches on walls.
Using kinematic triggers to resolve the players distance from a sound emitter is also a really useful tool, however the issue comes if the player is in range of two emitters at the same time which are using the same sound. Setting the gain of the sound object takes effect on ALL active voices.
It would be ideal if it was possible to set the gain for a specific voice. Perhaps when you send a play_sound
message, you’re able to provide an arbitrary ID, which is assigned to just the voice that is initiated from that call. When calling set_gain
, providing that ID again effects only the voice with that assigned ID.
Practically speaking, it is possible to just use one voice and just have the highest emitter distance win, but due to the way messages come in, this can lead to slight hiccups in the volume as a lower emitter might be the only one to send in collision responses in a specific frame. To get this method perfect, a lot of extra monitoring needs to be done, which is why I think the above case or something similar would be more elegant.