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
);
C# Syntax
RESULT System.set3DListenerAttributes(
int listener,
ref VECTOR pos,
ref VECTOR vel,
ref VECTOR forward,
ref VECTOR up
);
JavaScript Syntax
System.set3DListenerAttributes(
listener,
pos,
vel,
forward,
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
Vectors should use your chosen coordinate system, see 3D sounds for more information.
Orientation vectors must be 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.
NOTE! Users of the Studio API should call Studio::System::setListenerAttributes instead of this function.
See Also
Version 1.10.03 Built on Feb 1, 2018