# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLSOUND::CSourceCommon Class Reference

#include <source_common.h>

Inheritance diagram for NLSOUND::CSourceCommon:

NLSOUND::USource NLSOUND::CBackgroundSource NLSOUND::CComplexSource NLSOUND::CSimpleSource List of all members.

Public Types

enum  TSOURCE_TYPE { SOURCE_SIMPLE, SOURCE_COMPLEX, SOURCE_BACKGROUND }

Public Methods

 CSourceCommon (TSoundId id, bool spawn, TSpawnEndCallback cb, void *cbUserParam)
 ~CSourceCommon ()
virtual TSOURCE_TYPE getType () const=0
 Get the type the the source. More...

void setPriority (TSoundPriority pr)
 Change the priority of the source. More...

TSoundPriority getPriority () const
 Return the priority. More...

void setLooping (bool loop)
 Set looping on/off for future playbacks (default: off). More...

bool getLooping () const
 Return the looping state. More...

void play ()
 Play. More...

void stop ()
 Stop playing. More...

bool isPlaying ()
 Get playing state. Return false even if the source has stopped on its own. More...

void setPos (const NLMISC::CVector &pos)
 Set the position vector (default: (0,0,0)). More...

const NLMISC::CVectorgetPos () const
 Get the position vector (3D mode only). More...

void setVelocity (const NLMISC::CVector &vel)
 Set the velocity vector (3D mode only, ignored in stereo mode) (default: (0,0,0)). More...

void setDirection (const NLMISC::CVector &dir)
 Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional). More...

void setGain (float gain)
 Set the gain (volume value inside [0 , 1]). More...

void setRelativeGain (float gain)
 Set the gain amount (value inside [0, 1]) to map between 0 and the nominal gain (which is getSource()->getGain()). More...

float getRelativeGain () const
 Return the relative gain (see setRelativeGain()), or the absolute gain if getSource() is null. More...

void setSourceRelativeMode (bool mode)
 Set the source relative mode. If true, positions are interpreted relative to the listener position (default: false). More...

void * getCallbackUserParam (void) const
 return the user param for the user callback. More...

virtual void unregisterSpawnCallBack ()
 Tells this source not to call its callbacks when it ends. This is valid for spawned sources only. More...

virtual void getVelocity (NLMISC::CVector &vel) const
 Get the velocity vector. More...

virtual void getDirection (NLMISC::CVector &dir) const
 Get the direction vector. More...

virtual float getGain () const
 Get the gain. More...

virtual float getPitch () const
 Get the pitch. More...

virtual bool getSourceRelativeMode () const
 Get the source relative mode. More...

void set3DPositionVector (const NLMISC::CVector *pos)
 Set the position vector to return for a stereo source (default: NULL). More...

bool isSpawn () const
 Return the spawn state. More...

virtual void setPitch (float pitch)
 Shift the frequency. More...

virtual uint32 getTime ()
 Returns the number of milliseconds the source has been playing. More...


Protected Attributes

TSoundPriority _Priority
 Shift the frequency. More...

bool _Playing
bool _Looping
NLMISC::CVector _Position
NLMISC::CVector _Velocity
NLMISC::CVector _Direction
float _Gain
float _Pitch
bool _RelativeMode
float _InitialGain
 Gain not affected by setRelativeGain and used to compute _Gain. More...

NLMISC::TTime _PlayStart
const NLMISC::CVector_3DPosition
const bool _Spawn
TSpawnEndCallback _SpawnEndCb
void * _CbUserParam

Member Enumeration Documentation

enum NLSOUND::CSourceCommon::TSOURCE_TYPE
 

Enumeration values:
SOURCE_SIMPLE 
SOURCE_COMPLEX 
SOURCE_BACKGROUND 

Definition at line 40 of file source_common.h.

Referenced by NLSOUND::CSimpleSource::getType, NLSOUND::CComplexSource::getType, and NLSOUND::CBackgroundSource::getType.


Constructor & Destructor Documentation

NLSOUND::CSourceCommon::CSourceCommon TSoundId    id,
bool    spawn,
TSpawnEndCallback    cb,
void *    cbUserParam
 

Definition at line 36 of file source_common.cpp.

References id, NLSOUND::MidPri, NLSOUND::TSoundId, and NLSOUND::TSpawnEndCallback.

NLSOUND::CSourceCommon::~CSourceCommon  
 

Definition at line 56 of file source_common.cpp.


Member Function Documentation

void* NLSOUND::CSourceCommon::getCallbackUserParam void    const [inline]
 

return the user param for the user callback.

Definition at line 72 of file source_common.h.

References _CbUserParam.

virtual void NLSOUND::CSourceCommon::getDirection NLMISC::CVector   dir const [inline, virtual]
 

Get the direction vector.

Implements NLSOUND::USource.

Definition at line 78 of file source_common.h.

References _Direction.

virtual float NLSOUND::CSourceCommon::getGain void    const [inline, virtual]
 

Get the gain.

Implements NLSOUND::USource.

Definition at line 80 of file source_common.h.

References _Gain.

bool NLSOUND::CSourceCommon::getLooping   const [virtual]
 

Return the looping state.

Implements NLSOUND::USource.

Definition at line 88 of file source_common.cpp.

References _Looping.

virtual float NLSOUND::CSourceCommon::getPitch void    const [inline, virtual]
 

Get the pitch.

Implements NLSOUND::USource.

Definition at line 82 of file source_common.h.

References _Pitch.

const NLMISC::CVector & NLSOUND::CSourceCommon::getPos   const [virtual]
 

Get the position vector (3D mode only).

Implements NLSOUND::USource.

Definition at line 122 of file source_common.cpp.

References _3DPosition, and _Position.

TSoundPriority NLSOUND::CSourceCommon::getPriority void    const [inline]
 

Return the priority.

Definition at line 57 of file source_common.h.

References _Priority, and NLSOUND::TSoundPriority.

float NLSOUND::CSourceCommon::getRelativeGain   const [virtual]
 

Return the relative gain (see setRelativeGain()), or the absolute gain if getSource() is null.

Implements NLSOUND::USource.

Definition at line 186 of file source_common.cpp.

References _Gain, and _InitialGain.

virtual bool NLSOUND::CSourceCommon::getSourceRelativeMode   const [inline, virtual]
 

Get the source relative mode.

Implements NLSOUND::USource.

Definition at line 84 of file source_common.h.

References _RelativeMode.

uint32 NLSOUND::CSourceCommon::getTime   [virtual]
 

Returns the number of milliseconds the source has been playing.

Implements NLSOUND::USource.

Reimplemented in NLSOUND::CComplexSource.

Definition at line 203 of file source_common.cpp.

References _PlayStart, and uint32.

virtual TSOURCE_TYPE NLSOUND::CSourceCommon::getType   const [pure virtual]
 

Get the type the the source.

Implemented in NLSOUND::CBackgroundSource.

virtual void NLSOUND::CSourceCommon::getVelocity NLMISC::CVector   vel const [inline, virtual]
 

Get the velocity vector.

Implements NLSOUND::USource.

Definition at line 76 of file source_common.h.

References _Velocity.

bool NLSOUND::CSourceCommon::isPlaying   [inline, virtual]
 

Get playing state. Return false even if the source has stopped on its own.

Implements NLSOUND::USource.

Reimplemented in NLSOUND::CComplexSource.

Definition at line 62 of file source_common.h.

References _Playing.

bool NLSOUND::CSourceCommon::isSpawn   const [inline]
 

Return the spawn state.

Definition at line 88 of file source_common.h.

References _Spawn.

void NLSOUND::CSourceCommon::play   [virtual]
 

Play.

Implements NLSOUND::USource.

Reimplemented in NLSOUND::CBackgroundSource.

Definition at line 96 of file source_common.cpp.

References _Playing, and _PlayStart.

void NLSOUND::CSourceCommon::set3DPositionVector const NLMISC::CVector   pos [inline]
 

Set the position vector to return for a stereo source (default: NULL).

Definition at line 86 of file source_common.h.

References _3DPosition.

void NLSOUND::CSourceCommon::setDirection const NLMISC::CVector   dir [virtual]
 

Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional).

Implements NLSOUND::USource.

Reimplemented in NLSOUND::CBackgroundSource.

Definition at line 156 of file source_common.cpp.

References _Direction.

void NLSOUND::CSourceCommon::setGain float    gain [virtual]
 

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::USource.

Reimplemented in NLSOUND::CBackgroundSource.

Definition at line 167 of file source_common.cpp.

References _Gain, _InitialGain, and nlassert.

void NLSOUND::CSourceCommon::setLooping bool    loop [virtual]
 

Set looping on/off for future playbacks (default: off).

Implements NLSOUND::USource.

Reimplemented in NLSOUND::CSimpleSource.

Definition at line 80 of file source_common.cpp.

References _Looping, and NLAISCRIPT::l.

void NLSOUND::CSourceCommon::setPitch float    pitch [virtual]
 

Shift the frequency.

1.0f equals identity, each reduction of 50% equals a pitch shift of one octave. 0 is not a legal value.

Implements NLSOUND::USource.

Reimplemented in NLSOUND::CSimpleSource.

Definition at line 138 of file source_common.cpp.

References _Pitch, and nlassert.

void NLSOUND::CSourceCommon::setPos const NLMISC::CVector   pos [virtual]
 

Set the position vector (default: (0,0,0)).

3D mode -> 3D position st mode -> x is the pan value (from left (-1) to right (1)), set y and z to 0

Implements NLSOUND::USource.

Reimplemented in NLSOUND::CBackgroundSource.

Definition at line 114 of file source_common.cpp.

References _Position.

void NLSOUND::CSourceCommon::setPriority TSoundPriority    pr [virtual]
 

Change the priority of the source.

Implements NLSOUND::USource.

Definition at line 65 of file source_common.cpp.

References _Priority, and NLSOUND::TSoundPriority.

void NLSOUND::CSourceCommon::setRelativeGain float    gain [virtual]
 

Set the gain amount (value inside [0, 1]) to map between 0 and the nominal gain (which is getSource()->getGain()).

Does nothing if getSource() is null.

Implements NLSOUND::USource.

Reimplemented in NLSOUND::CBackgroundSource.

Definition at line 176 of file source_common.cpp.

References _Gain, _InitialGain, and nlassert.

void NLSOUND::CSourceCommon::setSourceRelativeMode bool    mode [virtual]
 

Set the source relative mode. If true, positions are interpreted relative to the listener position (default: false).

Implements NLSOUND::USource.

Reimplemented in NLSOUND::CSimpleSource.

Definition at line 197 of file source_common.cpp.

References _RelativeMode.

void NLSOUND::CSourceCommon::setVelocity const NLMISC::CVector   vel [virtual]
 

Set the velocity vector (3D mode only, ignored in stereo mode) (default: (0,0,0)).

Implements NLSOUND::USource.

Reimplemented in NLSOUND::CBackgroundSource.

Definition at line 148 of file source_common.cpp.

References _Velocity.

void NLSOUND::CSourceCommon::stop   [virtual]
 

Stop playing.

Implements NLSOUND::USource.

Reimplemented in NLSOUND::CBackgroundSource.

Definition at line 105 of file source_common.cpp.

References _Playing.

virtual void NLSOUND::CSourceCommon::unregisterSpawnCallBack   [inline, virtual]
 

Tells this source not to call its callbacks when it ends. This is valid for spawned sources only.

Implements NLSOUND::USource.

Definition at line 74 of file source_common.h.

References _SpawnEndCb.


Member Data Documentation

const NLMISC::CVector* NLSOUND::CSourceCommon::_3DPosition [protected]
 

Definition at line 171 of file source_common.h.

Referenced by getPos, and set3DPositionVector.

void* NLSOUND::CSourceCommon::_CbUserParam [protected]
 

Definition at line 176 of file source_common.h.

Referenced by getCallbackUserParam, NLSOUND::CSimpleSource::play, and NLSOUND::CSimpleSource::stop.

NLMISC::CVector NLSOUND::CSourceCommon::_Direction [protected]
 

Definition at line 159 of file source_common.h.

Referenced by NLSOUND::CSimpleSource::CSimpleSource, getDirection, NLSOUND::CSimpleSource::play, and setDirection.

float NLSOUND::CSourceCommon::_Gain [protected]
 

Definition at line 160 of file source_common.h.

Referenced by NLSOUND::CComplexSource::CComplexSource, NLSOUND::CSimpleSource::CSimpleSource, getGain, getRelativeGain, NLSOUND::CComplexSource::onEvent, NLSOUND::CComplexSource::onUpdate, NLSOUND::CBackgroundSource::onUpdate, NLSOUND::CSimpleSource::play, NLSOUND::CComplexSource::play, NLSOUND::CBackgroundSource::play, setGain, NLSOUND::CComplexSource::setGain, NLSOUND::CBackgroundSource::setGain, setRelativeGain, NLSOUND::CSimpleSource::setRelativeGain, NLSOUND::CComplexSource::setRelativeGain, and NLSOUND::CBackgroundSource::setRelativeGain.

float NLSOUND::CSourceCommon::_InitialGain [protected]
 

Gain not affected by setRelativeGain and used to compute _Gain.

Definition at line 165 of file source_common.h.

Referenced by NLSOUND::CSimpleSource::CSimpleSource, getRelativeGain, setGain, and setRelativeGain.

bool NLSOUND::CSourceCommon::_Looping [protected]
 

Definition at line 155 of file source_common.h.

Referenced by NLSOUND::CComplexSource::CComplexSource, NLSOUND::CSimpleSource::CSimpleSource, getLooping, NLSOUND::CComplexSource::onEvent, NLSOUND::CSimpleSource::play, and setLooping.

float NLSOUND::CSourceCommon::_Pitch [protected]
 

Definition at line 161 of file source_common.h.

Referenced by NLSOUND::CComplexSource::CComplexSource, NLSOUND::CSimpleSource::CSimpleSource, getPitch, NLSOUND::CSimpleSource::play, and setPitch.

bool NLSOUND::CSourceCommon::_Playing [protected]
 

Definition at line 154 of file source_common.h.

Referenced by NLSOUND::CComplexSource::getTime, isPlaying, NLSOUND::CSimpleSource::isPlaying, NLSOUND::CComplexSource::isPlaying, NLSOUND::CSimpleSource::onEvent, NLSOUND::CComplexSource::onEvent, NLSOUND::CComplexSource::onUpdate, play, stop, and NLSOUND::CSimpleSource::stop.

NLMISC::TTime NLSOUND::CSourceCommon::_PlayStart [protected]
 

Definition at line 168 of file source_common.h.

Referenced by NLSOUND::CSimpleSource::getPlayTime, getTime, NLSOUND::CComplexSource::getTime, and play.

NLMISC::CVector NLSOUND::CSourceCommon::_Position [protected]
 

Definition at line 157 of file source_common.h.

Referenced by getPos, NLSOUND::CComplexSource::onEvent, NLSOUND::CBackgroundSource::onEvent, NLSOUND::CSimpleSource::play, NLSOUND::CComplexSource::play, NLSOUND::CBackgroundSource::play, and setPos.

TSoundPriority NLSOUND::CSourceCommon::_Priority [protected]
 

Shift the frequency.

1.0f equals identity, each reduction of 50% equals a pitch shift of one octave. 0 is not a legal value.

Definition at line 153 of file source_common.h.

Referenced by NLSOUND::CComplexSource::CComplexSource, NLSOUND::CSimpleSource::CSimpleSource, getPriority, NLSOUND::CSimpleSource::play, and setPriority.

bool NLSOUND::CSourceCommon::_RelativeMode [protected]
 

Definition at line 162 of file source_common.h.

Referenced by getSourceRelativeMode, NLSOUND::CSimpleSource::play, and setSourceRelativeMode.

const bool NLSOUND::CSourceCommon::_Spawn [protected]
 

Definition at line 174 of file source_common.h.

Referenced by isSpawn.

TSpawnEndCallback NLSOUND::CSourceCommon::_SpawnEndCb [protected]
 

Definition at line 175 of file source_common.h.

Referenced by NLSOUND::CSimpleSource::getSpawnEndCallback, NLSOUND::CSimpleSource::play, NLSOUND::CSimpleSource::stop, and unregisterSpawnCallBack.

NLMISC::CVector NLSOUND::CSourceCommon::_Velocity [protected]
 

Definition at line 158 of file source_common.h.

Referenced by getVelocity, NLSOUND::CSimpleSource::play, and setVelocity.


The documentation for this class was generated from the following files: