# 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::CSourceUser Class Reference

Implementation of USource. More...

#include <source_user.h>

Inheritance diagram for NLSOUND::CSourceUser:

NLSOUND::USource NLSOUND::IPlayable List of all members.

Public Methods

 CSourceUser (TSoundId id=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam=0, CSoundContext *context=0, const std::string &buffername="")
 Constructor. More...

virtual ~CSourceUser ()
 Destructor. More...

virtual void setSound (TSoundId id, CSoundContext *context=0, const std::string &buffername="")
 Change the sound binded to the source. More...

virtual TSoundId getSound ()
 Return the sound binded to the source (or NULL if there is no sound). More...

virtual void setPriority (TSoundPriority pr, bool redispatch=true)
 Change the priority of the source. More...

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

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

virtual void getPos (NLMISC::CVector &pos) const
 Get the position vector. More...

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

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

virtual 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...

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

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

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

virtual 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...

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

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

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

virtual void setSourceRelativeMode (bool mode)
 Set the source relative mode. If true, positions are interpreted relative to the listener position (default: false). 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...

const NLMISC::CVectorgetPositionP () const
 Return a pointer to the position vector (3D mode only). More...

void enterTrack (CTrack *track)
 Set the corresponding track (NULL allowed, sets no track) Don't set a non-null track if getSound() is null. More...

void leaveTrack ()
 Unset the corresponding track. More...

CTrackgetTrack ()
 Return the track. More...

bool isStopped ()
 Return true if playing is finished or stop() has been called. More...

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

TSpawnEndCallback getSpawnEndCallback () const
 Return the spawn end callback. More...

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

virtual void enable (bool toplay, float gain)
 Enable (play with high priority) or disable (stop and set low priority). More...

virtual void moveTo (const NLMISC::CVector &pos)
 Move (set position). More...

virtual IBuffergetBuffer ()
 Serial sound and looping state (warning: partial serial). More...

Playback control
virtual void setLooping (bool l)
 Set looping on/off for future playbacks (default: off). More...

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

virtual void play ()
 Play. More...

virtual void stop ()
 Stop playing. More...

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

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

virtual NLMISC::TTicks getPlayTime ()

Static Public Methods

void init ()
 Static init (call at the very beginning). More...


Protected Methods

void copyToTrack ()
 Copy the source data into the corresponding track (_Track must be not null). More...


Private Attributes

CSound_Sound
std::string _Buffername
TSoundPriority _Priority
bool _Playing
bool _Looping
NLMISC::CVector _Position
NLMISC::CVector _Velocity
NLMISC::CVector _Direction
float _Gain
float _Pitch
bool _RelativeMode
CTrack_Track
const NLMISC::CVector_3DPosition
NLMISC::TTime _PlayStart
const bool _Spawn
TSpawnEndCallback _SpawnEndCb
void * _CbUserParam

Detailed Description

Implementation of USource.

Author:
Olivier Cado , Nevrax France
Date:
2001

Definition at line 50 of file source_user.h.


Constructor & Destructor Documentation

NLSOUND::CSourceUser::CSourceUser TSoundId    id = NULL,
bool    spawn = false,
TSpawnEndCallback    cb = 0,
void *    cbUserParam = 0,
CSoundContext   context = 0,
const std::string &    buffername = ""
 

Constructor.

Definition at line 44 of file source_user.cpp.

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

NLSOUND::CSourceUser::~CSourceUser   [virtual]
 

Destructor.

Definition at line 68 of file source_user.cpp.


Member Function Documentation

void NLSOUND::CSourceUser::copyToTrack   [protected]
 

Copy the source data into the corresponding track (_Track must be not null).

Definition at line 391 of file source_user.cpp.

References _Buffername, _Direction, _Gain, _Looping, _Pitch, _Position, _RelativeMode, _Sound, _Track, _Velocity, nlassert, and setDirection.

Referenced by enterTrack.

void NLSOUND::CSourceUser::enable bool    toplay,
float    gain
[virtual]
 

Enable (play with high priority) or disable (stop and set low priority).

Implements NLSOUND::IPlayable.

Definition at line 476 of file source_user.cpp.

References getPriority, getSound, NLSOUND::HighPri, NLSOUND::LowPri, play, setPriority, setRelativeGain, and stop.

void NLSOUND::CSourceUser::enterTrack CTrack   track
 

Set the corresponding track (NULL allowed, sets no track) Don't set a non-null track if getSound() is null.

Definition at line 416 of file source_user.cpp.

References _Buffername, _Sound, _Track, copyToTrack, nlassertex, and nlstopex.

Referenced by leaveTrack.

IBuffer * NLSOUND::CSourceUser::getBuffer   [virtual]
 

Serial sound and looping state (warning: partial serial).

Definition at line 138 of file source_user.cpp.

References _Buffername, and _Sound.

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

return the user param for the user callback.

Definition at line 159 of file source_user.h.

References _CbUserParam.

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

Get the direction vector.

Implements NLSOUND::USource.

Definition at line 112 of file source_user.h.

References _Direction.

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

Get the gain.

Implements NLSOUND::USource.

Definition at line 121 of file source_user.h.

References _Gain.

Referenced by getRelativeGain.

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

Return the looping state.

Implements NLSOUND::USource.

Definition at line 179 of file source_user.cpp.

References _Looping.

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

Get the pitch.

Implements NLSOUND::USource.

Definition at line 133 of file source_user.h.

References _Pitch.

virtual NLMISC::TTicks NLSOUND::CSourceUser::getPlayTime   [inline, virtual]
 

Definition at line 90 of file source_user.h.

References _PlayStart, and NLMISC::CTime::getLocalTime.

void NLSOUND::CSourceUser::getPos NLMISC::CVector   pos const [virtual]
 

Get the position vector.

If the source is stereo, return the position vector which reference was passed to set3DPositionVector()

Implements NLSOUND::USource.

Definition at line 242 of file source_user.cpp.

References _3DPosition, and _Position.

const NLMISC::CVector* NLSOUND::CSourceUser::getPositionP   const [inline]
 

Return a pointer to the position vector (3D mode only).

Definition at line 143 of file source_user.h.

References _Position.

TSoundPriority NLSOUND::CSourceUser::getPriority void    [inline]
 

Return the priority.

Definition at line 73 of file source_user.h.

References _Priority, and NLSOUND::TSoundPriority.

Referenced by enable.

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

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

Implements NLSOUND::USource.

Definition at line 339 of file source_user.cpp.

References _Gain, _Sound, and getGain.

virtual TSoundId NLSOUND::CSourceUser::getSound   [inline, virtual]
 

Return the sound binded to the source (or NULL if there is no sound).

Implements NLSOUND::USource.

Definition at line 69 of file source_user.h.

References _Sound, and NLSOUND::TSoundId.

Referenced by enable, and stop.

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

Get the source relative mode.

Implements NLSOUND::USource.

Definition at line 137 of file source_user.h.

References _RelativeMode.

TSpawnEndCallback NLSOUND::CSourceUser::getSpawnEndCallback   const [inline]
 

Return the spawn end callback.

Definition at line 157 of file source_user.h.

References _SpawnEndCb, and NLSOUND::TSpawnEndCallback.

CTrack* NLSOUND::CSourceUser::getTrack   [inline]
 

Return the track.

Definition at line 151 of file source_user.h.

References _Track.

Referenced by isPlaying, and isStopped.

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

Get the velocity vector.

Implements NLSOUND::USource.

Definition at line 108 of file source_user.h.

References _Velocity.

void NLSOUND::CSourceUser::init void    [inline, static]
 

Static init (call at the very beginning).

Definition at line 60 of file source_user.h.

bool NLSOUND::CSourceUser::isPlaying   [virtual]
 

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

Implements NLSOUND::USource.

Definition at line 534 of file source_user.cpp.

References _Buffername, _Looping, _Playing, _PlayStart, _Sound, getTrack, and nlassert.

Referenced by setSound.

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

Return the spawn state.

Definition at line 155 of file source_user.h.

References _Spawn.

bool NLSOUND::CSourceUser::isStopped  
 

Return true if playing is finished or stop() has been called.

Definition at line 581 of file source_user.cpp.

References _Buffername, _Looping, _Playing, _PlayStart, _Sound, and getTrack.

void NLSOUND::CSourceUser::leaveTrack  
 

Unset the corresponding track.

Definition at line 457 of file source_user.cpp.

References _Track, and enterTrack.

virtual void NLSOUND::CSourceUser::moveTo const NLMISC::CVector   pos [inline, virtual]
 

Move (set position).

Reimplemented from NLSOUND::IPlayable.

Definition at line 166 of file source_user.h.

References setPos.

void NLSOUND::CSourceUser::play   [virtual]
 

Play.

Implements NLSOUND::USource.

Definition at line 188 of file source_user.cpp.

References _Buffername, _Playing, _PlayStart, _Sound, _Track, and nlwarning.

Referenced by enable.

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

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

Definition at line 141 of file source_user.h.

References _3DPosition.

void NLSOUND::CSourceUser::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.

Definition at line 274 of file source_user.cpp.

References _Buffername, _Direction, _Sound, _Track, and NLMISC::CVector::isNull.

Referenced by copyToTrack.

void NLSOUND::CSourceUser::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.

Definition at line 310 of file source_user.cpp.

References _Gain, _Track, and nlassert.

Referenced by setRelativeGain.

void NLSOUND::CSourceUser::setLooping bool    l [virtual]
 

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

Implements NLSOUND::USource.

Definition at line 166 of file source_user.cpp.

References _Looping, _Track, and NLAISCRIPT::l.

void NLSOUND::CSourceUser::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.

Definition at line 359 of file source_user.cpp.

References _Pitch, _Track, and nlassert.

void NLSOUND::CSourceUser::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.

Definition at line 227 of file source_user.cpp.

References _Position, and _Track.

Referenced by moveTo.

void NLSOUND::CSourceUser::setPriority TSoundPriority    pr,
bool    redispatch = true
[virtual]
 

Change the priority of the source.

Implements NLSOUND::USource.

Definition at line 150 of file source_user.cpp.

References _Priority, and NLSOUND::TSoundPriority.

Referenced by enable.

void NLSOUND::CSourceUser::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.

Definition at line 326 of file source_user.cpp.

References _Sound, nlassert, and setGain.

Referenced by enable.

void NLSOUND::CSourceUser::setSound TSoundId    id,
CSoundContext   context = 0,
const std::string &    buffername = ""
[virtual]
 

Change the sound binded to the source.

Implements NLSOUND::USource.

Definition at line 85 of file source_user.cpp.

References _Buffername, _Direction, _Gain, _Looping, _Pitch, _Priority, _Sound, _Track, id, isPlaying, nlassert, nlwarning, stop, and NLSOUND::TSoundId.

Referenced by CSourceUser.

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

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

Implements NLSOUND::USource.

Definition at line 375 of file source_user.cpp.

References _RelativeMode, and _Track.

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

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

Implements NLSOUND::USource.

Definition at line 259 of file source_user.cpp.

References _Track, and _Velocity.

void NLSOUND::CSourceUser::stop   [virtual]
 

Stop playing.

Implements NLSOUND::USource.

Definition at line 211 of file source_user.cpp.

References _Playing, _Track, getName, getSound, nldebug, and nlinfo.

Referenced by enable, and setSound.

virtual void NLSOUND::CSourceUser::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 88 of file source_user.h.

References _SpawnEndCb.


Member Data Documentation

const NLMISC::CVector* NLSOUND::CSourceUser::_3DPosition [private]
 

Definition at line 201 of file source_user.h.

Referenced by getPos, and set3DPositionVector.

std::string NLSOUND::CSourceUser::_Buffername [private]
 

Definition at line 185 of file source_user.h.

Referenced by copyToTrack, enterTrack, getBuffer, isPlaying, isStopped, play, setDirection, and setSound.

void* NLSOUND::CSourceUser::_CbUserParam [private]
 

Definition at line 209 of file source_user.h.

Referenced by getCallbackUserParam.

NLMISC::CVector NLSOUND::CSourceUser::_Direction [private]
 

Definition at line 192 of file source_user.h.

Referenced by copyToTrack, getDirection, setDirection, and setSound.

float NLSOUND::CSourceUser::_Gain [private]
 

Definition at line 193 of file source_user.h.

Referenced by copyToTrack, getGain, getRelativeGain, setGain, and setSound.

bool NLSOUND::CSourceUser::_Looping [private]
 

Definition at line 188 of file source_user.h.

Referenced by copyToTrack, getLooping, isPlaying, isStopped, setLooping, and setSound.

float NLSOUND::CSourceUser::_Pitch [private]
 

Definition at line 194 of file source_user.h.

Referenced by copyToTrack, getPitch, setPitch, and setSound.

bool NLSOUND::CSourceUser::_Playing [private]
 

Definition at line 187 of file source_user.h.

Referenced by isPlaying, isStopped, play, and stop.

NLMISC::TTime NLSOUND::CSourceUser::_PlayStart [private]
 

Definition at line 204 of file source_user.h.

Referenced by getPlayTime, isPlaying, isStopped, and play.

NLMISC::CVector NLSOUND::CSourceUser::_Position [private]
 

Definition at line 190 of file source_user.h.

Referenced by copyToTrack, getPos, getPositionP, and setPos.

TSoundPriority NLSOUND::CSourceUser::_Priority [private]
 

Definition at line 186 of file source_user.h.

Referenced by getPriority, setPriority, and setSound.

bool NLSOUND::CSourceUser::_RelativeMode [private]
 

Definition at line 195 of file source_user.h.

Referenced by copyToTrack, getSourceRelativeMode, and setSourceRelativeMode.

CSound* NLSOUND::CSourceUser::_Sound [private]
 

Definition at line 183 of file source_user.h.

Referenced by copyToTrack, enterTrack, getBuffer, getRelativeGain, getSound, isPlaying, isStopped, play, setDirection, setRelativeGain, and setSound.

const bool NLSOUND::CSourceUser::_Spawn [private]
 

Definition at line 207 of file source_user.h.

Referenced by isSpawn.

TSpawnEndCallback NLSOUND::CSourceUser::_SpawnEndCb [private]
 

Definition at line 208 of file source_user.h.

Referenced by getSpawnEndCallback, and unregisterSpawnCallBack.

CTrack* NLSOUND::CSourceUser::_Track [private]
 

Definition at line 198 of file source_user.h.

Referenced by copyToTrack, enterTrack, getTrack, leaveTrack, play, setDirection, setGain, setLooping, setPitch, setPos, setSound, setSourceRelativeMode, setVelocity, and stop.

NLMISC::CVector NLSOUND::CSourceUser::_Velocity [private]
 

Definition at line 191 of file source_user.h.

Referenced by copyToTrack, getVelocity, and setVelocity.


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