# Some basic questions about the 3D mode

**URL:** <https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881>\
**Category:** FMOD Engine\
**Created:** [June 12, 2022, 11:39am UTC](https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881 "2022-06-12T11:39:07Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiyongman](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jiyongman](https://qa.fmod.com/u/jiyongman)\
**Post date:** [June 12, 2022, 11:39am UTC](https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881/1 "2022-06-12T11:39:07Z")

</div>

I’ve been using FMOD\_2D mode, so I’m not familiar with the 3D mode.  
I’m trying to convert one of my old projects to 3D mode, and have some questions.

1. If all the objects don’t move and the listener’s position is fixed at the center position, do I still need to initialize the listener by calling `set3DListenerAttributes()` with the following values?

```auto
FMOD_VECTOR listenerpos = { 0.0f, 0.0f, 0.0f };
FMOD_VECTOR forward	= { 0.0f, 0.0f, 1.0f };
FMOD_VECTOR up = { 0.0f, 1.0f, 0.0f };
FMOD_VECTOR vel = { 0.0f, 0.0f, 0.0f };

```

1. How can I set the orientation using `set3DAttributes()`?  
I have some stereo sound sources, and so I need to set the forward directions for them.

2. Can `FMOD_DSP_PAN_3D_*` and `FMOD_DSP_OBJECTPAN_3D_*` be used together with `set3DAttributes()`?

3. Can I keep using `FMOD_DSP_TYPE_SFXREVERB` instead of the 3D reverb?  
I was using it just for the global background effect.

4. Will my existing DSPs (PITCHSHIFT, FLANGE, CHORUS, DISTORTION, LIMITER, COMPRESSOR, THREE\_EQ) work as before with the 3D reverb without any code modifications?

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [June 16, 2022, 4:08am UTC](https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881/2 "2022-06-16T04:08:23Z")

</div>

> [@jiyongman](#):
>
> If all the objects don’t move and the listener’s position is fixed at the center position, do I still need to initialize the listener by calling `set3DListenerAttributes()` with the following values?

It won’t hurt, but it won’t make a difference.

> [@jiyongman](#):
>
> How can I set the orientation using `set3DAttributes()`?  
> I have some stereo sound sources, and so I need to set the forward directions for them.

Orientation/rotation is calculated from the `forward` and `up` [unit vectors](https://en.wikipedia.org/wiki/Unit_vector). If you were to define orientation in terms of pitch and yaw, this would be the way to calculate appropriate forward and up vectors.

```auto
forward.x = cos(pitch) * sin(yaw);
forward.y = -sin(pitch);
forward.z = cos(pitch) * cos(yaw);
up.x = sin(pitch) * sin(yaw);
up.y = cos(pitch);
up.z = sin(pitch) * cos(yaw);

```

> [@jiyongman](#):
>
> Can `FMOD_DSP_PAN_3D_*` and `FMOD_DSP_OBJECTPAN_3D_*` be used together with `set3DAttributes()`?

Yes, `set3DAttributes` will tell the spatializer where it is, so you should use `set3DAttributes` in conjunction with spatializers.

> [@jiyongman](#):
>
> Can I keep using `FMOD_DSP_TYPE_SFXREVERB` instead of the 3D reverb?  
> I was using it just for the global background effect.

You can still use the reverb DSP, 3D reverb is just for setting a 3D position for the reverb, and automatically attenuating the wet level of the reveb signal based on distance.

> [@jiyongman](#):
>
> Will my existing DSPs (PITCHSHIFT, FLANGE, CHORUS, DISTORTION, LIMITER, COMPRESSOR, THREE\_EQ) work as before with the 3D reverb without any code modifications?

All your existing DSPs will work fine.

---

<div class="post-metadata">

**Author:** ![jiyongman](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jiyongman](https://qa.fmod.com/u/jiyongman)\
**Post date:** [June 16, 2022, 8:19am UTC](https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881/3 "2022-06-16T08:19:41Z")

</div>

Thank you very much for the detailed answer.  
All my doubts were cleared thanks to it, except for the number two.  
I asked the question because `set3DAttributes()` only takes two parameters unlike `set3DListenerAttributes()`.  
There’s no way to pass the forward and up vectors, which was my real question.

I want to give a user options to rotate both the camera (which is a listener) and the game characters such as a drummer.

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [June 17, 2022, 12:03am UTC](https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881/4 "2022-06-17T00:03:09Z")

</div>

Oh so you are using [`ChannelControl::set3DAttributes`](https://fmod.com/resources/documentation-api?version=2.02&page=core-api-channelcontrol.html#channelcontrol_set3dattributes) and not [`Studio::EventInstance::set3DAttributes`](https://fmod.com/resources/documentation-api?version=2.02&page=studio-api-eventinstance.html#studio_eventinstance_set3dattributes)? If you are using Channels / Core API, you can set orientation using [`ChannelControl::set3DConeOrientation`](https://fmod.com/resources/documentation-api?version=2.02&page=core-api-channelcontrol.html#channelcontrol_set3dconeorientation), and adjust the sound’s directivity using [`ChannelControl::set3DConeSettings`](https://fmod.com/resources/documentation-api?version=2.02&page=core-api-channelcontrol.html#channelcontrol_set3dconesettings).

---

<div class="post-metadata">

**Author:** ![jiyongman](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jiyongman](https://qa.fmod.com/u/jiyongman)\
**Post date:** [June 18, 2022, 6:30am UTC](https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881/5 "2022-06-18T06:30:00Z")

</div>

Thanks for those two functions.  
I would never know they existed because those weren’t introduced in both the example file **3d.cpp** and **White Paper** on **3D Sounds** at all.  
It seems useful in some cases and I may utilize them in the future.  
But what I want to achieve by rotating sounds now isn’t the volume attenuation effect.

Let’s say you have a set of drums in front of you.  
If we rotate the set 180 degrees, a hi-hat cymbal will be placed on the right instead of the left.  
That’s what I want.  
But today I realized that just switching from `FMOD_2D` to `FMOD_3D` collapses stereo channels into mono. My sound immediately lost all the details.

[White Paper](https://www.fmod.com/resources/documentation-api?version=2.02&page=white-papers-3d-sounds.html#stereo-and-multi-channel-sounds-can-be-3d) said:

> Stereo and multi-channel sounds can be 3D!
> 
> A stereo sound when played as 3d, will be split into 2 mono voices internally which are separately 3d positionable. Multi-channel sounds are also supported, so an 8 channel sound for example will allocate 8 mono voices internally in FMOD. To rotate the left and right part of the stereo 3d sound in 3D space, use the ChannelControl::set3DSpread function. By default the subchannels position themselves in the same place, therefore sounding ‘mono’.

So I tried the `ChannelControl::set3DSpread()` with different values but it made no difference at all, even though the function returned `FMOD_OK`.

1. Can I preserve the stereo channels when using the `FMOD_3D` mode?  
At least, it needs to sound the exact same as the `FMOD_2D` when both the listener and the sound source are in the initial state at the center. And the separate channels should be audible when the listener is close to the sound source.  
I even tried `FMOD_3D_HEADRELATIVE` as suggested on the **White Paper** , but it just followed the listener with a mono channel.

2. How do I rotate the stereo sound sources. (I don’t care about the attenuation here.)

3. Is what I understood in the below comment correct?

---

<div class="post-metadata">

**Author:** ![jiyongman](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jiyongman](https://qa.fmod.com/u/jiyongman)\
**Post date:** [June 18, 2022, 6:42am UTC](https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881/6 "2022-06-18T06:42:21Z")

</div>

[White Paper](https://www.fmod.com/resources/documentation-api?version=2.02&page=white-papers-3d-sounds.html#some-global-3d-settings) says:

> All 3 settings can be set with System::set3DSettings. Generally the user will not want to set these.

But the example file **3d.cpp** uses the function, and multiplies the distance factor value all over the place like below :

```auto
...
const float DISTANCEFACTOR = 1.0f; // Units per meter. I.e feet would = 3.28. centimeters would = 100.
...
/*
	Set the distance units. (meters/feet etc).
*/
result = system->set3DSettings(1.0, DISTANCEFACTOR, 1.0f);
...
result = sound1->set3DMinMaxDistance(0.5f * DISTANCEFACTOR, 5000.0f * DISTANCEFACTOR);
...
FMOD_VECTOR pos = { -10.0f * DISTANCEFACTOR, 0.0f, 0.0f };
FMOD_VECTOR vel = { 0.0f, 0.0f, 0.0f };
...
result = channel1->set3DAttributes(&pos, &vel);
...

```

And [this page](https://fmod.com/resources/documentation-api?version=2.02&page=core-api-system.html#system_set3dsettings) explains the `distancefactor` saying “This only affects doppler”.

So I’m confused.  
I concluded this way.

- The `distancefactor` value set by the `System::set3DSettings()` is only used to set the “minimum distance” values of new instances automatically.
- In general, I don’t need to call `set3DAttributes()` at all, but still, all the position and velocity vectors are needed to be multiplied by the distance factor.
- If all the objects and listeners in the game are fixed or don’t need any doppler effects, then both calling `set3DAttributes()` and multiplying by the distance factor aren’t needed.

Am I correct?

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [June 24, 2022, 7:16am UTC](https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881/7 "2022-06-24T07:16:58Z")

</div>

> [@jiyongman](#):
>
> If we rotate the set 180 degrees, a hi-hat cymbal will be placed on the right instead of the left.  
> That’s what I want.

I see what you mean now. Can you can try adding a pan DSP to rotate the sound of an `FMOD_2D` event? eg

```cpp
system->playSound(sound1, 0, false, &channel);

FMOD::DSP *dsp;
system->createDSPByType(FMOD_DSP_TYPE_PAN, &dsp);

channel->addDSP(0, dsp);
dsp->setParameterFloat(FMOD_DSP_PAN_2D_ROTATION, 180.0f);

```

You still need to call `Channel::set3DAttributes` to set a sound’s x,y,z position in space, regardless of whether you are using doppler. You are correct `System::set3DSettings` is only required if you want finer control over doppler.

---

<div class="post-metadata">

**Author:** ![jiyongman](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jiyongman](https://qa.fmod.com/u/jiyongman)\
**Post date:** [June 24, 2022, 9:56am UTC](https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881/8 "2022-06-24T09:56:49Z")

</div>

Oops. Stupid mistake in my question. It was `set3DSettings` not `set3DAttributes`.  
Thanks for the confirmation about the `set3DSettings`.

As for `set3DAttributes`, even when I don’t use doppler,  
do I still need to pass position vectors multiplied by the distance factor?

About the `FMOD_DSP_TYPE_PAN` trick, I’ll try and tell you the result when I get back home,  
but I don’t think it will help, because the FMOD\_3D sound is mono in the first place as explained above.  
To be honest, I can give up on the rotation feature if it’s really hard, but not on the stereo sounds.

Anyway, I’ll come back and let you know soon.

Update:  
No difference.  
As said earlier, it becomes mono sound, so for now, I would be happy if I can prevent it at least aside from the rotation,  
so that players can hear original stereo sounds when they get closer to each sound source.

`ChannelControl::set3DSpread()` does something to the sound source, but not the way I expected.  
For instance, if the sound is located at { -1000.0f, 0.0f, 0.0f }, I can hear it from the left.  
If I call `set3DSpread` and pass the value 180, I hear it from the center.  
And with the value 360, from the right.

---

<div class="post-metadata">

**Author:** ![jiyongman](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jiyongman](https://qa.fmod.com/u/jiyongman)\
**Post date:** [June 26, 2022, 12:17pm UTC](https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881/9 "2022-06-26T12:17:47Z")

</div>

I’ve been tinkering with the `FMOD_3D` this weekend and noticed strange behaviors.

I could turn an `FMOD_3D` sound into a stereo sound by calling `ChannelControl::set3DSpread()` with the value **180** , but there are some catches.

Only certain combinations of x, y, and z of the position vector worked.  
I was testing with different values to see if there’s a rule or something but soon gave up for other reasons, which I will explain below.  
Anyway, below are some combinations I tested.

```
{ 0.0f, 0.0f, 0.0f } : Mono at the center
{ 0.0f, 0.0f, 0.000000001f }	: Stereo at the center
{ 0.0f, 0.0f, -0.000000001f }	: Mono at the far left
{ -50.0f, -50.0f, -50.0f } : Stereo at the center
{ 50.0f, 50.0f, 50.0f } : Stereo at the center
{ 0.000000001f,	0.000000001f,	0.000000001f }	: Stereo at the center
{ 0.0f, 0.000000001f,	0.000000001f }	: Stereo at the center
{ 0.0f, -0.000000001f,	0.000000001f }	: Stereo at the center
{ 0.000000001f,	0.0, 0.000000001f }	: Stereo at the center
{ -0.000000001f,0.0, 0.000000001f }	: Stereo at the center
{ 0.0f, 0.00000001f,	0.000000001f }	: Mono at the center
{ 0.0f, -0.00000001f,	0.000000001f }	: Mono at the center
{ 0.00000001f,	0.0, 0.000000001f }	: Mono at the center
{ -0.00000001f,	0.0, 0.000000001f }	: Mono at the center
{ -5000.0f, -5000.0f, 5000.0f } : Stereo at the center
{ 0.0f, 0.0f, 5000.0f } : Stereo at the center

```

I stopped testing because :

- If a different value is passed to `ChannelControl::set3DSpread`, then different combinations are needed.

- After setting the 3D spread thing, the sound doesn’t work as other `FMOD_3D` sounds anymore. I tried many different positions, but all I got was one of the three types as listed above.  
“Mono at the center, Stereo at the center, and Mono at the far left.”  
I couldn’t locate the sound at the exact position I wanted at all.

- After adding `FMOD_DSP_TYPE_PAN` to the channel, it suddenly feels like as if `set3DSpread` was called with the value **85** or something. I mean, it feels much narrower than **180**.

- Whatever I do with `FMOD_DSP_PAN_2D_ROTATION`, it didn’t make any difference at all.

Sorry for spamming here.  
Let me ask again:

1. When I don’t use doppler, do I still need to pass position vectors multiplied by the distance factor to `set3DAttributes`?
2. Is there any way to locate a stereo sound in a 3D space?

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [July 1, 2022, 1:21am UTC](https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881/10 "2022-07-01T01:21:16Z")

</div>

> [@jiyongman](#):
>
> do I still need to pass position vectors multiplied by the distance factor?

If you aren’t using doppler then there is no need to scale things by the distance factor.

> [@jiyongman](#):
>
> No difference.  
> As said earlier, it becomes mono sound, so for now, I would be happy if I can prevent it at least aside from the rotation,

Try adding the FMOD\_DSP\_TYPE\_PAN on an `FMOD_2D` sound instead of an `FMOD_3D` sound to esnure the channel configuration is preserved. I have found this has allowed a stereo sound to be positioned in 3D space.

---

<div class="post-metadata">

**Author:** ![jiyongman](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jiyongman](https://qa.fmod.com/u/jiyongman)\
**Post date:** [July 1, 2022, 8:37pm UTC](https://qa.fmod.com/t/some-basic-questions-about-the-3d-mode/18881/11 "2022-07-01T20:37:24Z")

</div>

Thank you for the confirmation.

As for the `FMOD_DSP_TYPE_PAN` and `FMOD_DSP_PAN_2D_ROTATION`, I finally got it to work with an `FMOD_3D` sound!

I don’t know why the API User Manual here doesn’t explain this, but there are four conditions.

- `FMOD_DSP_PAN_MODE` must be set to `FMOD_DSP_PAN_MODE_SURROUND`. (This is the default setting.)
- `FMOD_DSP_PAN_2D_STEREO_MODE` must be set to `FMOD_DSP_PAN_2D_STEREO_MODE_DISTRIBUTED`. (This is NOT the default setting!)
- Calling `set3DSpread` with 180 is needed to get stereo channels back. (The default value is 0, and this merges all the channels into mono.)
- 3D position of the sound is important as stated above.

Firstly, I set `FMOD_DSP_PAN_MODE` to `FMOD_DSP_PAN_MODE_STEREO` because the channels of sound sources and speakers are stereo.

Secondly, I didn’t care about `FMOD_DSP_PAN_2D_STEREO_MODE` at all because only `FMOD_DSP_PAN_2D_STEREO_AXIS`, `FMOD_DSP_PAN_2D_STEREO_SEPARATION`, `FMOD_DSP_PAN_2D_EXTENT`, and `FMOD_DSP_PAN_2D_DIRECTION` are mentioned in the manual.

So, yes, with proper settings, it’s possible to rotate an `FMOD_3D` sound AT THE CENTER.  
But as I said above, positioning a stereo sound in 3D is the most important thing.

Switching to `FMOD_2D` is not what I want.

With `FMOD_2D`, all the 3D functions such as `set3DAttributes` won’t work.  
To some extent, we can do simple tricks with 2D panning but it is not exactly the same as 3D positioning.

Is there really no way to locate a stereo sound with an `FMOD_3D` flag in 3D?  
This is my last unsolved, but the most important question here.

Update : In the previous comment, I said:

> After adding `FMOD_DSP_TYPE_PAN` to the channel, it suddenly feels like as if `set3DSpread` was called with the value **85** or something. I mean, it feels much narrower than **180**.

This was due to the default `FMOD_DSP_PAN_MODE_SURROUND` mode.  
When I switched to `FMOD_DSP_PAN_MODE_STEREO`, the dsp didn’t ruin the stereo sound.  
But with this mode, `FMOD_DSP_PAN_2D_ROTATION` doesn’t work.  
So, I give up on the rotation feature.
