Firelight Technologies FMOD Studio API

System::set3DListenerAttributes

This updates the position, velocity and orientation of the specified 3D sound listener.

C++ Syntax

FMOD_RESULT System::set3DListenerAttributes(
  int listener,
  const FMOD_VECTOR *pos,
  const FMOD_VECTOR *vel,
  const FMOD_VECTOR *forward,
  const FMOD_VECTOR *up
);

C Syntax

FMOD_RESULT FMOD_System_Set3DListenerAttributes(
  FMOD_SYSTEM *system,
  int listener,
  const FMOD_VECTOR *pos,
  const FMOD_VECTOR *vel,
  const FMOD_VECTOR *forward,
  const FMOD_VECTOR *up
);

Parameters

listener
Listener ID in a multi-listener environment. Specify 0 if there is only 1 listener.
pos
The position of the listener in world space, measured in distance units. You can specify 0 or NULL to not update the position.
vel
The velocity of the listener measured in distance units per second. You can specify 0 or NULL to not update the velocity of the listener.
forward
The forwards orientation of the listener. This vector must be of unit length and perpendicular to the up vector. You can specify 0 or NULL to not update the forwards orientation of the listener.
up
The upwards orientation of the listener. This vector must be of unit length and perpendicular to the forwards vector. You can specify 0 or NULL to not update the upwards orientation of the listener.

Return Values

If the function succeeds then the return value is FMOD_OK.
If the function fails then the return value will be one of the values defined in the FMOD_RESULT enumeration.

Remarks

By default, FMOD uses a left-handed co-ordinate system. This means +X is right, +Y is up, and +Z is forwards.
To change this to a right-handed coordinate system, use FMOD_INIT_3D_RIGHTHANDED. This means +X is right, +Y is up, and +Z is backwards or towards you.

To map to another coordinate system, flip/negate and exchange these values.

Orientation vectors are expected to be of UNIT length. This means the magnitude of the vector should be 1.0.

A 'distance unit' is specified by System::set3DSettings. By default this is set to meters which is a distance scale of 1.0.

Always remember to use units per second, not units per frame as this is a common mistake and will make the doppler effect sound wrong.

For example, Do not just use (pos - lastpos) from the last frame's data for velocity, as this is not correct. You need to time compensate it so it is given in units per second.

You could alter your pos - lastpos calculation to something like this.

vel = (pos-lastpos) / time_taken_since_last_frame_in_seconds.

I.e. at 60fps the formula would look like this vel = (pos-lastpos) / 0.0166667.

See Also




Version 1.03.06 Built on Apr 17, 2014