Can't get FMOD_Channel_Set3DSpread to work

Edit: I got it to work, but it seems like the sound only becomes spread out once the listener isn’t standing right on top of it. Is there any way to retain the stereo image even when the sound is right in the center?
Greetings,

I am trying to implement FMOD into my game, and I ran into an issue with playing stereo 3d sounds.
The documentation says that playing stereo sounds results in the separate channels being played as two separate voices, and that the width can be adjusted with FMOD_Channel_Set3DSpread.
What I’ve tried: Creating a new sample with a stereo file, playing it with paused set to true, calling FMOD_Channel_Set3DSpread(channel, 360), but the sound still gets collapsed to a mono mix of left+right instead of being spaced out.
I have tried different angle values, none of them sound much different.
Am I supposed to somehow retrieve the sub-voices and spread them out individually?
I’m using the core API from C.

Thank you for any help.

Hi,

What version of FMOD are you using? Would it be possible to get a code snippet uploaded to look over?

Thank you for responding, and my apologies for the delayed reply.
My header file says:
#define FMOD_VERSION 0x00020212 /* 0xaaaabbcc → aaaa = product version, bb = major version, cc = minor version.*/
I’m just calling FMOD_System_Create with the version constant, FMOD_System_Init with FMOD_INIT_NORMAL, FMOD_System_CreateSound with the UTF8 string containing the path to the sound, and FMOD_CREATESAMPLE|FMOD_3D|FMOD_LOOP_NORMAL as the mode, and then calling FMOD_System_PlaySound with paused set to true, and then to make the stereo file wide, I call FMOD_Channel_Set3DSpread with 150 degrees (I’ve tried different values, anything above 150 doesn’t sound right to me). I also call FMOD_System_Set3DListenerAttributes and FMOD_System_Update every frame.
The problem I have is that when the listener z is equal to sound z, the sound collapses to mono (as if my 3d spread was set to default/0) when I would prefer it to sound the same (spread out) as if listener z was less than sound’s z.
Another problem is that when listener z is grater than sound’s z, the sound image rotates so that left channel becomes the right one and vice versa, which confuses me because listener is still facing forward.
I hope that makes sense/I’d appreciate any pointers on how to get the behavior I desire.
Sometimes I have a river sound for example that would sound bad being collapsed to mono if the listener is standing inside the river. I can understand it being collapsed to mono if the listener is standing to the left or right of the source, but I’d expect it to slowly start widening as I approach the sound source’s middle, and then slowly start narrowing as I start going toward its left edge, which is the behavior I get if the listener is +z or -z, with the issue that +z reverses the sound channels.
I hope I have understood things correctly: by default (left-handed coordinate system) means that +x=right, -x=left, +y=above, -y=below, +z=in front, -z=behind?
In the engine I have been using so far, y was in front/behind, and z was above/below, so I hope I have understood that correctly.

Hi,

Thank you for the explanation. I was not able to reproduce the issue in our core examples. Would it be possible to get a stripped-out project where you are experiencing this?

Hi, happy belated Easter if you celebrate.
It took me a while to make a demo, but here it is. There’s a test.wav file in the zip which has a sine wave hard-panned to the right, and brown noise hard-panned to the left.
The code cycles the listener z between -1, 0, and 1, and back to -1 every 1 second. -1 (at least here) sounds stereo, if a bit narrower than the original, 0 sounds completely mono, and 1 sounds stereo as well, but now the sine is on the left, and brown noise is on the right.
I have compiled fmod.exe with gcc, there’s a make.bat included.
I could just be doing something wrong, but the reason I wish for sounds not to lose their proper image is because in my games and many other audio games, there are stereo ambiences like a static river loop, or crowd that still need to position themselves (so 2d wouldn’t work), but I wouldn’t like for them to be channel-flipped or downmixed to mono.
I could of course be doing something silly…
I don’t see an upload file option, so here’s a link: https://nsstudiosweb.com/downloads/fmodDemo.zip
Thank you.

1 Like

Hi, happy easter!

Thank you very much for the demo, it was very useful.

What I am experiencing is instead of your listener moving on the z-axis rather it is rotating around the y-axis which is why the sound is rotating around the listener. Can I confirm that you are wanting to have the sound’s stay on their respective sides while the listener moves back and forth?

Included with the FMOD Engine download there are some API examples, specifically a 3D example which I think might display the behavior you are looking for. It should be found under "X:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\core\examples\3d.cpp", there may be some information included in the example that may solve the issue.

Again, thank you for the demo and I hope this helps!

Thank you for the response, I appreciate it a lot.
I did take a look at the 3d.cpp example, but I see changing of the x axis only. My games are usually 3d in the sense that x=walking left/right, z=walking forward/backward, and y=climbing up/down or jumping all without changing the direction that the listener is facing.
The only field in the position vector that I’m changing is z, and to my understanding z represents +z=in front, -z=behind, while +x=right, -x=left, +y=above, -y=below; is that incorrect?
When I change pos.z, I expect it to be absolute coordinate change without any rotation/facing change, so my expectation is the listener just moves from 0,0,-1 to 0,0,0, to 0,0,1, and jumps back to 0,0,-1 with facing forward the whole time.
Hopefully that makes sense.
Thank you.

Hi,

Could you enable Live Update in your engine using the FMOD_STUDIO_INIT_LIVEUPDATE init flag (FMOD API | Studio API System - Initialize) and connect the FMOD Studio - Profiler and keep an eye on the 3D View (Profiler - Overview)
image
Which will show the current position of the emitter in relation to the listener. What we would expect to see is the emitter moving back and forth. Hopefully, this will shed some light on the movement you are experiencing.

Greetings,

Thank you for the answer.
Unfortunately if the profiler is graphical in nature, I wouldn’t be able to use it.
Can you confirm that by default in core API +x represents right, +y up, and +z in front?
The documentation seems unclear when it comes to that:
Note for plugin writers: FMOD always uses a left-handed coordinate system when passing 3D data to plugins. This coordinate system is fixed to use +X = right, +Y = up, +Z = forward. When the system is initialised to use right-handed coordinates FMOD will flip the Z component of vectors before passing them to plugins.
VS
By default FMOD uses a left-handed coordinate system. The positive Y axis points up, the positive X axis points to the right, and the positive Z axis points away from the listener.
I would just like to move left/right (x), up/down (y), and back and forth (z), no rotation or facing direction change involved.
Are you trying to say that z rotates y?

Correct.

Would it be possible to get a code snippet of how you are getting the position of the listener and then moving it?

No, I was just describing what I was hearing. But that could also be explained if the listener was moving from side to side. If I could have a look at the code you are using to move the listener it may shed some light on what is happening.

If you would prefer you can upload files to your profile after registering a project with us.

Thanks again for the response.
As My earlier demo shows, I just have an FMOD_VECTOR with x y z values that are incremented/decremented every time the user steps in a certain direction. An up arrow walks forward, the z is increased by 1. Down arrow does the backward walking, z is decreased by 1. Left/right arrows decrease/increase x by 1 respectively, and jumping or climbing increase/decrease y, then I just pass the vector to the FMOD_System_Set3DListenerAttributes in my main loop.
I could make a quick example if that would help, but I’m still confused as to why would the sound flip if the listener hasn’t changed the facing direction. If I walk passed a pair of speakers, for example, even if they were behind me, the left one would still be to my left, the right would be on my right. they wouldn’t flip on me unless I had turned my head, or turned my whole body around 180 degrees. As far as I understand, the controls that control facing are the const FMOD_VECTOR *forward, const FMOD_VECTOR *up params instead.
I can understand why the sound would go mono, but you said you couldn’t reproduce that, so I’m confused if that’s a feature or not.

Hi,

Apologies for the delayed response. Using your project I was able to reproduce the issue. I will pass it to the development team to look into further, once there is more information I can share I will let you know.

Again thank you for the demo it was extremely helpful trying to find the issue.

No problem. Thank you for looking into it further. I’m probably just doing something wrong, but I look forward to getting the definitive answer/solution.

1 Like