Synced Diegetic Sounds using FMOD + Unity


The Problem


I have a GameObject that is spawned by the player that emits 3d spatialized music. It lives for a time, and then dies. Several of these can be spawned by multiple players, so multiple instances can be on the screen at one time.

The problem is, the music emitted by these objects is not subtle. So they were clashing magnificently whenever there was more than one on the screen.

I had a few options - making the sound 2D (though you wouldn’t be able to use the sound to track one of these items down in the world), setting the sound’s Max Instances to 1 (though that might be a little misleading when there are several onscreen), having an emitter tied to the player character whose position was set to the nearest of these objects (similar issues to the prior, though slightly more accurate) or figure out how in the hell to have two emitters synchronized. Which seemed like the best options.

So, how do I synchronize two FMOD emitters in Unity?

Having multiple emitters whose sound effects were synchronized should be right out of the box, I thought to myself. So I googled my butt off trying to figure out how I could accomplish this and kept coming up with BUPKIS. Maybe I was asking the wrong question.

How do I play the same FMOD event from two emitters in Unity?

Still didn’t find much. Eventually, a teammate linked me to a forum post that seemed to be talking about what I wanted:

https://qa.fmod.com/t/fmod-event-played-through-multiple-sources/13354

I’d come across this post earlier in the day and had abandoned it because when I searched for information on transceivers I’d found a lot more bupkis. But now that it had come back around, I dove a bit deeper. I don’t know if sound engineers have a different google or speak a special language, but I’m apparently really bad at finding documentation online about how to do any of this. Finally, I found one persistent forum poster who insisted ‘yeah, but HOW do I use it?’.

https://qa.fmod.com/t/how-exactly-do-i-use-the-transceiver-plugin/14168

After fussing around a bit more with this new information, I managed to get a setup where when I created one of these objects it played the expected music, and when I dropped another it played the same music in perfect synchronization with the first.

Below is the setup I used (please keep in mind that I’m not an FMOD expert so I’m sorry for my bad terminology). Hope it’s useful to someone.


Implementation


Create two events in FMOD, one of them 2D, one of them 3D.

Add a transceiver effect to both of them. (Right click in the bottom area and AddEfffect > FMOD Transceiver. Set your 2D sound to Transmit, and your 3D one to Receive. Make sure they’re both pointing to the same channel.

Transmit.png
Recieve.png

Set your receiver to be persistent. If you don’t, it will be culled and never play.

 
Persistent.png
 

Add whatever distance attenuation and volume you want for the music/sound effect on your receiver. Leave the timeline blank.

On your transmitter, add your music/sound to the timeline and apply whatever loop region you need. Set the volume to zero.

In Unity, create a GameObject that is set up to survive for as long as you might be creating the objects that you want to emit sound (differs depending on your setup). Add an FMOD_StudioEventEmitter component and have it play your Transmit event throughout its lifetime. It will sit in the scene playing the music on loop (at zero volume) for the entire time. When your speaker objects are created, they will receive music from this transmitter and play it at the appropriate volume. This emitter should not make any noise. If it does, make sure that the event is set to zero volume.

 
TransmitterGameObject.png
 

You can now add a Studio Event Emitter to the objects that you want to emit music/sound. Set them to play the Receiver event. When you spawn them, they should play the music being sent out by the Transmitter.


So that’s the setup I used to achieve the effect I wanted. I’m not sure if this is one of those situations where everyone knows about Transceivers and that’s why there’s no documentation, or no one does and it’s not needed as often as I think. Either way, I thought I’d write up a little TIL in case I need to revisit this in the future.