0
0

Hello.
I’m very new with fmod.
I have a problem with [u:2uz4wc5f]set3DListenerAttributes[/u:2uz4wc5f]. It does not have any effect on the percieved sound. Whatever values I give the listner is always centered at origo facing [b:2uz4wc5f]positive[/b:2uz4wc5f] z, head up. (the listener z-value of 80 and facing negative z is totally ignored)

The folowing code is a cut’n paste version of the code, as it is run. It’s originally run in different objects. Can you see anything errorous?

[code:2uz4wc5f]
result = FMOD::System_Create(&system);
ERRCHECK(result);

result = system->init(100, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);

result = system->set3DSettings(1.0, DISTANCEFACTOR, 1.0f);
ERRCHECK(result);

result = system->createStream("audio/Fest i går kväll.ogg", FMOD_LOOP_NORMAL, 0, &snd_music);
ERRCHECK(result);
result = system->createSound("audio/engine.wav", FMOD_3D | FMOD_LOOP_NORMAL, 0, &snd_engine);
ERRCHECK(result);

result = system->playSound(FMOD_CHANNEL_FREE, snd_engine, true, &ch_dsp);
ERRCHECK(result);
result = ch_dsp->setPaused(false);
ERRCHECK(result);

FMOD_VECTOR pos = { 0.0f, 0.0f, 80.0f };
FMOD_VECTOR forward = { 0.0f, 0.0f, -1.0f };
FMOD_VECTOR up = { 0.0f, 1.0f, 0.0f };

[/code:2uz4wc5f]…[code:2uz4wc5f]

static FMOD_VECTOR lastpos = { 0.0f, 0.0f, 0.0f };
FMOD_VECTOR vel;

vel.x = (pos.x – lastpos.x) * (1000 / INTERFACE_UPDATETIME);
vel.y = (pos.y – lastpos.y) * (1000 / INTERFACE_UPDATETIME);
vel.z = (pos.z – lastpos.z) * (1000 / INTERFACE_UPDATETIME);

lastpos = pos;

result = system->set3DListenerAttributes(0, &pos, &vel, &forward, &up);
ERRCHECK(result);

[/code:2uz4wc5f]…[code:2uz4wc5f]

pos.z = -2.0f;

for (int i=1;i>0;i++)
{
pos.x = 5*(float)sin((float)i/10);
static FMOD_VECTOR lastpos = { 0.0f, 0.0f, 0.0f };
FMOD_VECTOR vel;

vel.x = (pos.x - lastpos.x) * (1000 / INTERFACE_UPDATETIME);
vel.y = (pos.y - lastpos.y) * (1000 / INTERFACE_UPDATETIME);
vel.z = (pos.z - lastpos.z) * (1000 / INTERFACE_UPDATETIME);

lastpos = pos;

result = ch_dsp->set3DAttributes(&pos, &vel);
ERRCHECK(result);

system->update();
Sleep(INTERFACE_UPDATETIME - 1);

}
[/code:2uz4wc5f]

/Anders

  • You must to post comments
0
0

Yes. pos.x is a float all the time…

This is the actual code:

[code:1t5mj74p]void SoundWorld::setListener(FMOD_VECTOR pos, FMOD_VECTOR forward, FMOD_VECTOR up)
{
static FMOD_VECTOR lastpos = { 0.0f, 0.0f, 0.0f };
FMOD_VECTOR vel;

// vel = how far we moved last FRAME (m/f), then time compensate it to SECONDS (m/s).
vel.x = (pos.x - lastpos.x) * (1000 / INTERFACE_UPDATETIME);
vel.y = (pos.y - lastpos.y) * (1000 / INTERFACE_UPDATETIME);
vel.z = (pos.z - lastpos.z) * (1000 / INTERFACE_UPDATETIME);

// store pos for next time
lastpos = pos;

result = system->set3DListenerAttributes(0, &pos, &vel, &forward, &up);
ERRCHECK(result);

}[/code:1t5mj74p]

I’ve tries lots of different values of pos, front and up. Nothing makes any difference.

Changing the pos of the soundsource on the other hand works fine…

/A

  • You must to post comments
0
0

Problem solved.
The problem was that I accidently used a whole new system in my child class…
No wonder it didn’t work.
Thanx for all help.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.