NLSOUND::CSourceCommon Class Reference

#include <source_common.h>

Inherits NLSOUND::USource.

Inherited by NLSOUND::CBackgroundSource, NLSOUND::CComplexSource, NLSOUND::CMusicSource, and NLSOUND::CSimpleSource.

List of all members.

Public Types

enum  TSOURCE_TYPE { SOURCE_SIMPLE, SOURCE_COMPLEX, SOURCE_BACKGROUND, SOURCE_MUSIC }

Public Member Functions

 CSourceCommon (TSoundId id, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster)
 ~CSourceCommon ()
virtual TSOURCE_TYPE getType () const =0
 Get the type the the source.
void setPriority (TSoundPriority pr)
 Change the priority of the source.
TSoundPriority getPriority () const
 Return the priority.
void setLooping (bool loop)
 Set looping on/off for future playbacks (default: off).
bool getLooping () const
 Return the looping state.
void play ()
 Play.
void stop ()
 Stop playing.
bool isPlaying ()
 Get playing state. Return false even if the source has stopped on its own.
void setPos (const NLMISC::CVector &pos)
 Set the position vector (default: (0,0,0)).
const NLMISC::CVectorgetPos () const
 Get the position vector (3D mode only).
void setVelocity (const NLMISC::CVector &vel)
 Set the velocity vector (3D mode only, ignored in stereo mode) (default: (0,0,0)).
void setDirection (const NLMISC::CVector &dir)
 Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional).
void setGain (float gain)
 Set the gain (volume value inside [0 , 1]).
void setRelativeGain (float gain)
 Set the gain amount (value inside [0, 1]) to map between 0 and the nominal gain (which is getSource()->getGain()).
float getRelativeGain () const
 Return the relative gain (see setRelativeGain()), or the absolute gain if getSource() is null.
void setSourceRelativeMode (bool mode)
 Set the source relative mode. If true, positions are interpreted relative to the listener position (default: false).
void * getCallbackUserParam (void) const
 return the user param for the user callback
virtual void unregisterSpawnCallBack ()
 Tells this source not to call its callbacks when it ends. This is valid for spawned sources only.
virtual void getVelocity (NLMISC::CVector &vel) const
 Get the velocity vector.
virtual void getDirection (NLMISC::CVector &dir) const
 Get the direction vector.
virtual float getGain () const
 Get the gain.
virtual float getPitch () const
 Get the pitch.
virtual bool getSourceRelativeMode () const
 Get the source relative mode.
void set3DPositionVector (const NLMISC::CVector *pos)
 Set the position vector to return for a stereo source (default: NULL).
bool isSpawn () const
 Return the spawn state.
virtual void setPitch (float pitch)
 Shift the frequency.
virtual uint32 getTime ()
 Returns the number of milliseconds the source has been playing.
NL3D::CClustergetCluster () const
virtual void checkup ()
 This method is called from backgroup sound to check if subsound need to be restarted (ie subsound in loop mode).

Protected Attributes

TSoundPriority _Priority
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.
NLMISC::TTime _PlayStart
const NLMISC::CVector_3DPosition
const bool _Spawn
TSpawnEndCallback _SpawnEndCb
void * _CbUserParam
NL3D::CCluster_Cluster
NLMISC::TStringId _UserVarControler
 An optional user var controler.

Friends

class CAudioMixerUser

Detailed Description

Definition at line 35 of file source_common.h.


Member Enumeration Documentation

Enumerator:
SOURCE_SIMPLE 
SOURCE_COMPLEX 
SOURCE_BACKGROUND 
SOURCE_MUSIC 

Definition at line 40 of file source_common.h.


Constructor & Destructor Documentation

NLSOUND::CSourceCommon::CSourceCommon ( TSoundId  id,
bool  spawn,
TSpawnEndCallback  cb,
void *  cbUserParam,
NL3D::CCluster cluster 
)
NLSOUND::CSourceCommon::~CSourceCommon (  ) 

Member Function Documentation

virtual void NLSOUND::CSourceCommon::checkup (  )  [inline, virtual]

This method is called from backgroup sound to check if subsound need to be restarted (ie subsound in loop mode).

Reimplemented in NLSOUND::CComplexSource.

Definition at line 102 of file source_common.h.

Referenced by NLSOUND::CBackgroundSoundManager::updateBackgroundStatus().

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

return the user param for the user callback

Definition at line 73 of file source_common.h.

References _CbUserParam.

NL3D::CCluster* NLSOUND::CSourceCommon::getCluster (  )  const [inline]

Definition at line 97 of file source_common.h.

References _Cluster.

Referenced by NLSOUND::CSimpleSource::getVirtualPos(), and NLSOUND::CAudioMixerUser::update().

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

Get the direction vector.

Implements NLSOUND::USource.

Definition at line 79 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 81 of file source_common.h.

References _Gain.

Referenced by NLSOUND::CAudioMixerUser::update().

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

Return the looping state.

Implements NLSOUND::USource.

Definition at line 97 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 83 of file source_common.h.

References _Pitch.

const NLMISC::CVector & NLSOUND::CSourceCommon::getPos (  )  const [virtual]
TSoundPriority NLSOUND::CSourceCommon::getPriority ( void   )  const [inline]
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 203 of file source_common.cpp.

References _Gain, and _InitialGain.

Referenced by NLSOUND::CAudioMixerUser::addUserControledSource(), and NLSOUND::CAudioMixerUser::update().

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

Get the source relative mode.

Implements NLSOUND::USource.

Definition at line 85 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, and NLSOUND::CSimpleSource.

Definition at line 220 of file source_common.cpp.

References _Playing, and _PlayStart.

virtual TSOURCE_TYPE NLSOUND::CSourceCommon::getType (  )  const [pure virtual]
virtual void NLSOUND::CSourceCommon::getVelocity ( NLMISC::CVector vel  )  const [inline, virtual]

Get the velocity vector.

Implements NLSOUND::USource.

Definition at line 77 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, and NLSOUND::CSimpleSource.

Definition at line 63 of file source_common.h.

References _Playing.

Referenced by NLSOUND::CMusicSource::play(), NLSOUND::CAudioMixerUser::reset(), NLSOUND::CMusicSource::stop(), NLSOUND::CBackgroundSoundManager::updateBackgroundStatus(), and NLSOUND::CMusicSource::~CMusicSource().

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

Return the spawn state.

Definition at line 89 of file source_common.h.

References _Spawn.

void NLSOUND::CSourceCommon::play (  )  [virtual]
void NLSOUND::CSourceCommon::set3DPositionVector ( const NLMISC::CVector pos  )  [inline]

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

Definition at line 87 of file source_common.h.

References _3DPosition.

Referenced by NLSOUND::CAudioMixerUser::createSource().

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, NLSOUND::CComplexSource, and NLSOUND::CSimpleSource.

Definition at line 173 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, NLSOUND::CComplexSource, and NLSOUND::CSimpleSource.

Definition at line 184 of file source_common.cpp.

References _Gain, _InitialGain, and NLMISC::clamp().

Referenced by NLSOUND::CAudioMixerUser::addUserControledSource().

void NLSOUND::CSourceCommon::setLooping ( bool  l  )  [virtual]

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

Implements NLSOUND::USource.

Reimplemented in NLSOUND::CSimpleSource.

Definition at line 89 of file source_common.cpp.

References _Looping.

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 155 of file source_common.cpp.

References _Pitch.

Referenced by NLSOUND::CAudioMixerUser::addUserControledSource().

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, NLSOUND::CComplexSource, and NLSOUND::CSimpleSource.

Definition at line 131 of file source_common.cpp.

References _Position.

Referenced by NLSOUND::CBackgroundSoundManager::updateBackgroundStatus().

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

Change the priority of the source.

Implements NLSOUND::USource.

Definition at line 74 of file source_common.cpp.

References _Priority.

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, NLSOUND::CComplexSource, and NLSOUND::CSimpleSource.

Definition at line 193 of file source_common.cpp.

References _Gain, _InitialGain, and NLMISC::clamp().

Referenced by NLSOUND::CAudioMixerUser::addUserControledSource(), and NLSOUND::CBackgroundSoundManager::updateBackgroundStatus().

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 214 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, NLSOUND::CComplexSource, and NLSOUND::CSimpleSource.

Definition at line 165 of file source_common.cpp.

References _Velocity.

void NLSOUND::CSourceCommon::stop (  )  [virtual]
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 75 of file source_common.h.

References _SpawnEndCb.


Friends And Related Function Documentation

friend class CAudioMixerUser [friend]

Definition at line 37 of file source_common.h.


Member Data Documentation

Definition at line 124 of file source_common.h.

Referenced by getPos(), and set3DPositionVector().

Gain not affected by setRelativeGain and used to compute _Gain.

Definition at line 118 of file source_common.h.

Referenced by CSourceCommon(), getRelativeGain(), setGain(), and setRelativeGain().

Definition at line 121 of file source_common.h.

Referenced by getTime(), NLSOUND::CComplexSource::getTime(), and play().

An optional user var controler.

Definition at line 133 of file source_common.h.

Referenced by play(), and stop().

Definition at line 111 of file source_common.h.

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


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

Generated on Thu Jan 7 08:30:23 2010 for NeL by  doxygen 1.6.1