2D positonal sounds

We’re working on a 2D (top-down) game and want to place sounds in the world that are positional (only in that they get quiet/loud based on your distance). So far, I’ve been using FMOD_Studio_System_SetListenerAttributes and FMOD_Studio_EventInstance_Set3DAttributes and it “kind of works”, but the fall off curves seem wrong. I’ve been setting the Z cord to 0 to simulate 2D, but I’m not sure what to do about FMOD_3D_ATTRIBUTES.forward and FMOD_3D_ATTRIBUTES.up and how min/max distance or SoundSize affect any of this in 2D.

I tried using a distance parameter but that requires me to keep track of all the sounds and apply the distance parms on each one rather than letter FMOD handle all of this.

I’m starting to wonder if I’m going about this all wrong and there is an easier way.

I should also mention that the L and R channels are switched (when the object is on the left, the audio favors the R channel, not the L. What I’d like to do (and what I thought sound size did) if your inside some radius, the sounds is equally L and R, only when you go outside does it become LR positional.

I did some more tests using the default parameter Distance, and that works well for sound volume based on distance, but the LR channel balance still seems to be controlled by FMOD (and is flipped). The other issue affecting volume is when the sound is predominantly coming out of one LR channel, your brain reads it as a lower volume.

All this probably works well in 3D, but in 2D it doesn’t feel right.

Hello Ron,

In regards to having an event become 2D when close to the listener, you can do this within the FMOD Studio application and don’t need to use coding.

First add a Distance built-in parameter to an event. Then automate the “pan override” mix dial, available by clicking on the triangle in the center of Spatializer effect. Automate it so when the event instance is within a certain range of the listener, the mix becomes 100%.

https://www.fmod.com/resources/documentation-studio?page=built-in-parameters-reference.html#distance
https://www.fmod.com/resources/documentation-studio?page=glossary.html#spatializer-effect

This will cause the event instance to behave as if it was 2D.

I’ll note that you don’t need to set the values of a built-in distance parameter, FMOD will take those values from the game world automatically.

In regards to the left and right channels being switched, can you make sure you are initializing FMOD to use the same co-ordination as your game? If the left and right co-ordinates are flipped, then you can initialize with FMOD_INIT_3D_RIGHTHANDED.

https://www.fmod.com/resources/documentation-api?page=content/generated/overview/3dsound.html

You also mention you wish to only have distance attenuation, if you don’t want panning to occur then you can set the “Min Extent” property of the Spatializer to 360 degrees.

Thanks,
Richard

1 Like

Thanks, I finally solved all my issues. The min and max distance does what I need for fall off, not sure why it was working the first time (user error).

I also figure out the LR panning issue. Being a 2D game, I was using XY, but it seems FMOD would rather I use XZ since it’s in 3D. Once I got the forward/up vectors correct, then LR panning started working.

1 Like

Thanks Richard! It wonders for me!

Apologies for jumping onto an old thread, but does this logic apply if using the resonance audio plugin included in FMOD studio?

Yes, the same logic will apply but you will be automating the “Spread” property on the Resonance source effect.