#include <listener_al.h>
Inheritance diagram for NLSOUND::CListenerAL:
For arguments as 3D vectors, use the NeL vector coordinate system (not OpenAL/OpenGL's one).
Nevrax France
Definition at line 46 of file listener_al.h.
Public Member Functions | |
CListenerAL () | |
Constructor. | |
virtual | ~CListenerAL () |
Destructor. | |
Listener properties | |
virtual float | getGain () const |
Get the gain. | |
virtual void | getOrientation (NLMISC::CVector &front, NLMISC::CVector &up) const |
Get the orientation vectors. | |
virtual const NLMISC::CVector & | getPos () const |
virtual void | getVelocity (NLMISC::CVector &vel) const |
Get the velocity vector. | |
virtual void | setGain (float gain) |
virtual void | setOrientation (const NLMISC::CVector &front, const NLMISC::CVector &up) |
Set the orientation vectors (3D mode only) (default: (0,1,0), (0,0,1)). | |
virtual void | setPos (const NLMISC::CVector &pos) |
Set the position vector (default: (0,0,0)) (3D mode only). | |
virtual void | setVelocity (const NLMISC::CVector &vel) |
Set the velocity vector (3D mode only) (default: (0,0,0)). | |
Global properties | |
virtual void | setDopplerFactor (float f) |
Set the doppler factor (default: 1) to exaggerate or not the doppler effect. | |
virtual void | setEAXProperty (uint prop, void *value, uint valuesize) |
Set any EAX listener property if EAX available. | |
virtual void | setEnvironment (uint env, float size=7.5f) |
Set DSPROPERTY_EAXLISTENER_ENVIRONMENT and DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE if EAX available (see EAX listener properties). | |
virtual void | setRolloffFactor (float f) |
Set the rolloff factor (default: 1) to scale the distance attenuation effect. | |
Static Public Member Functions | |
CListenerAL * | instance () |
Return the instance of the singleton. | |
Private Attributes | |
NLMISC::CVector | _Pos |
Static Private Attributes | |
CListenerAL * | _Instance = NULL |
|
Constructor.
Definition at line 45 of file listener_al.cpp. References nlerror.
|
|
Destructor.
Definition at line 96 of file listener_al.h.
00096 { _Instance = NULL; } |
|
Get the gain.
Implements NLSOUND::IListener. Definition at line 177 of file listener_al.cpp. References TestALError.
00178 { 00179 ALfloat gain; 00180 #ifdef NL_OS_WINDOWS 00181 alGetListenerf( AL_GAIN, &gain ); 00182 #else 00183 alGetListenerfv( AL_GAIN, &gain ); 00184 #endif 00185 TestALError(); 00186 return gain; 00187 } |
|
Get the orientation vectors.
Implements NLSOUND::IListener. Definition at line 149 of file listener_al.cpp. References NLMISC::CVector::set(), TestALError, and v.
00150 { 00151 // Forward then up 00152 ALfloat v[6]; 00153 alGetListenerfv( AL_ORIENTATION, v ); 00154 TestALError(); 00155 // Coordsys conversion 00156 front.set( v[0], -v[2], v[1] ); 00157 up.set( v[3], -v[5], v[4] ); 00158 } |
|
Get the position vector. See setPos() for details. Implements NLSOUND::IListener. Definition at line 73 of file listener_al.cpp.
00074 { 00075 return _Pos; 00076 00077 // Currently, the OpenAL headers are different between Windows and Linux versions ! 00078 // alGetListener3f() is part of the spec, though. 00079 /* 00080 #ifdef NL_OS_WINDOWS 00081 // Coordsys conversion 00082 float glposz; 00083 alGetListener3f( AL_POSITION, &pos.x, &pos.z, &glposz ); 00084 pos.y = -glposz; 00085 #else 00086 float posarray [3]; 00087 alGetListenerfv( AL_POSITION, posarray ); 00088 // Coordsys conversion 00089 pos.set( posarray[0], -posarray[2], posarray[1] ); 00090 #endif 00091 TestALError(); 00092 */ 00093 } |
|
Get the velocity vector.
Implements NLSOUND::IListener. Definition at line 110 of file listener_al.cpp. References NLMISC::CVector::set(), TestALError, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.
00111 { 00112 #ifdef NL_OS_WINDOWS 00113 // Coordsys conversion 00114 float glposz; 00115 alGetListener3f( AL_VELOCITY, &vel.x, &vel.z, &glposz ); 00116 vel.y = - glposz; 00117 #else 00118 float velarray [3]; 00119 alGetListenerfv( AL_VELOCITY, velarray ); 00120 // Coordsys conversion 00121 vel.set( velarray[0], -velarray[2], velarray[1] ); 00122 #endif 00123 TestALError(); 00124 } |
|
Return the instance of the singleton.
Definition at line 54 of file listener_al.h.
00054 { return _Instance; } |
|
Set the doppler factor (default: 1) to exaggerate or not the doppler effect.
Implements NLSOUND::IListener. Definition at line 193 of file listener_al.cpp. References TestALError.
00194 { 00195 alDopplerFactor( f ); 00196 TestALError(); 00197 } |
|
Set any EAX listener property if EAX available.
Implements NLSOUND::IListener. Definition at line 228 of file listener_al.cpp.
00229 { 00230 #if EAX_AVAILABLE == 1 00231 if ( EAXSetProp != NULL ) 00232 { 00233 EAXSetProp( &DSPROPSETID_EAX_ListenerProperties, prop, 0, value, valuesize ); 00234 } 00235 #endif 00236 } |
|
Set DSPROPERTY_EAXLISTENER_ENVIRONMENT and DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE if EAX available (see EAX listener properties).
Implements NLSOUND::IListener. Definition at line 213 of file listener_al.cpp.
00214 { 00215 #if EAX_AVAILABLE == 1 00216 if ( EAXSetProp != NULL ) 00217 { 00218 EAXSetProp( &DSPROPSETID_EAX_ListenerProperties, DSPROPERTY_EAXLISTENER_ENVIRONMENT, 0, &env, sizeof(unsigned long) ); 00219 EAXSetProp( &DSPROPSETID_EAX_ListenerProperties, DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE, 0, &size, sizeof(float) ); 00220 } 00221 #endif 00222 } |
|
Set the gain (volume value inside [0 , 1]). (default: 1) 0.0 -> silence 0.5 -> -6dB 1.0 -> no attenuation values > 1 (amplification) not supported by most drivers Implements NLSOUND::IListener. Definition at line 167 of file listener_al.cpp. References TestALError.
00168 { 00169 alListenerf( AL_GAIN, gain ); 00170 TestALError(); 00171 } |
|
Set the orientation vectors (3D mode only) (default: (0,1,0), (0,0,1)).
Implements NLSOUND::IListener. Definition at line 130 of file listener_al.cpp. References TestALError, v, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.
|
|
Set the position vector (default: (0,0,0)) (3D mode only).
Implements NLSOUND::IListener. Definition at line 61 of file listener_al.cpp. References TestALError.
00062 { 00063 _Pos = pos; 00064 // Coordinate system: conversion from NeL to OpenAL/GL: 00065 alListener3f( AL_POSITION, pos.x, pos.z, -pos.y ); 00066 TestALError(); 00067 } |
|
Set the rolloff factor (default: 1) to scale the distance attenuation effect.
Implements NLSOUND::IListener. Definition at line 203 of file listener_al.cpp. References nlassert.
00204 { 00205 nlassert( CSoundDriverAL::instance() != NULL ); 00206 CSoundDriverAL::instance()->applyRolloffFactor( f ); 00207 } |
|
Set the velocity vector (3D mode only) (default: (0,0,0)).
Implements NLSOUND::IListener. Definition at line 99 of file listener_al.cpp. References TestALError, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.
00100 { 00101 // Coordsys conversion 00102 alListener3f( AL_VELOCITY, vel.x, vel.z, -vel.y ); 00103 TestALError(); 00104 } |
|
Definition at line 39 of file listener_al.cpp. |
|
Definition at line 103 of file listener_al.h. |