0
0

I have 1 sound playing and 1 listener set up to receive the sound.

When I move the channel’s position around, I get the sound’s volume decreasing as the channel pulls away which is correct I am assuming.

When I move the 3D Listener around away from the channel, I do not get any change in sound. Can someone please explain what I am doing wrong.

[code:376a8pt7]
FMOD::System* m_pSystem;
FMOD::Sound* m_pSound;
FMOD::Channel* m_pChannel;

FMOD::System_Create(&m_pSystem);    
m_pSystem->init(100, FMOD_INIT_NORMAL, 0);

m_pSystem->createSound( "D:/wave4.wav", FMOD_SOFTWARE | FMOD_3D, 0, &m_pSound );

FMOD_VECTOR _position;
FMOD_VECTOR _position2;
FMOD_VECTOR _velocity;
FMOD_VECTOR _velocity2;
FMOD_VECTOR _foward;
FMOD_VECTOR _up;

_position.x = 0;
_position.y = 0;
_position.z = 0;

_position2.x = 0;
_position2.y = 0;
_position2.z = 0;

_velocity.x = 0;
_velocity.y = 0;
_velocity.z = 0;

_velocity2.x = 0;
_velocity2.y = 0;
_velocity2.z = 0;

_foward.x = 0;
_foward.y = 0;
_foward.z = 0;

_up.x = 0;
_up.y = 0;
_up.z = 0;

while( bLoop == true )
{
    if( iLoopControl > 1000 )
    {
        bLoop = false;
    }
    _position2.x += (a value);
    m_pChannel->set3DAttributes( &_position2, &_velocity2 );
    m_pSystem->set3DListenerAttributes( 0, &_position, &_velocity, &_foward, &_up );

    m_pSystem->update();
}

[/code:376a8pt7]

  • You must to post comments
0
0

That code moves the channel not the listener.
Your listener orientation vectors are wrong. Please read the documentation. You need 2 vectors, which are each unit length, and perpendicular to each other.

  • You must to post comments
0
0

Thanks for replyin.

I’ve changed the orientation of the 3d listener, so these values should be correct now.

In the case above, I switched the channel position with the 3d listener’s position (so I am now moving the 3d listener, and not the channel). The result was as if the sound was not moving at all.

Moving the 3d listener should have given me a change in the sound’s volume

Can you please correct me where I have gone wrong.

  • You must to post comments
0
0

It works fine. You have some strange things, like not waiting between update calls, so you are making it execute the loop extremely quickly.
Also your code doesnt have a playsound call.
I modified the code only slightly, it still worked even if i did
_position.x += 0.1f;
or
_position2.x += 0.1f;

[code:3d3yaz52]
FMOD::System* m_pSystem;
FMOD::Sound* m_pSound;
FMOD::Channel* m_pChannel;

FMOD::System_Create(&m_pSystem);
m_pSystem->init(100, FMOD_INIT_NORMAL, 0);

m_pSystem->createSound( "c:/media/drumloop.wav", FMOD_SOFTWARE | FMOD_3D | FMOD_LOOP_NORMAL, 0, &m_pSound );

FMOD_VECTOR _position;
FMOD_VECTOR _position2;
FMOD_VECTOR _velocity;
FMOD_VECTOR _velocity2;
FMOD_VECTOR _foward;
FMOD_VECTOR _up;

_position.x = 0;
_position.y = 0;
_position.z = 0;

_position2.x = 0;
_position2.y = 0;
_position2.z = 0;

_velocity.x = 0;
_velocity.y = 0;
_velocity.z = 0;

_velocity2.x = 0;
_velocity2.y = 0;
_velocity2.z = 0;

_foward.x = 0;
_foward.y = 0;
_foward.z = 1;

_up.x = 0;
_up.y = 1;
_up.z = 0;

bool bLoop = true;
int iLoopControl = 0;
m_pSystem->playSound(FMOD_CHANNEL_FREE, m_pSound, false, &m_pChannel);

while( bLoop == true )
{
if( iLoopControl > 1000 )
{
bLoop = false;
}
_position.x += 0.1f;
m_pChannel->set3DAttributes( &_position2, &_velocity2 );
m_pSystem->set3DListenerAttributes( 0, &_position, &_velocity, &_foward, &_up );

  m_pSystem->update(); 
  Sleep(10);

}
[/code:3d3yaz52]

  • You must to post comments
0
0

m_pChannel->set3DAttributes( &[color=red:1km4qgi0]_position[/color:1km4qgi0], &_velocity2 );
m_pSystem->set3DListenerAttributes( 0, &[color=red:1km4qgi0]_position2[/color:1km4qgi0], &_velocity, &_foward, &_up );

This could should be moving the listener away from the channel if im not mistaken?

However the result is sound that seems as if the volume is not changing at all

  • You must to post comments
0
0

The code i pasted works. Overwrite one of the examples in fmod with that code and set it to ../media/drumloop.wav instead and it will work.

  • You must to post comments
0
0

thanks a lot for your help. It turns out, I was playing around with the wrong listener ID ><.

Ah the silly mistakes make you want to murder kittens at times 😮

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.