SFXSource Class Reference

#include <sfxSource.h>

Inheritance diagram for SFXSource:

Inheritance graph
[legend]
List of all members.

Detailed Description

A source is a scriptable controller for all aspects of sound playback.


Public Member Functions

 DECLARE_CONOBJECT (SFXSource)
 SFXSource ()
 The default constructor is *only* here to satisfy the construction needs of IMPLEMENT_CONOBJECT.
bool hasVoice () const
 This is normally called from the system to detect if this source has been assigned a voice for playback.
void play ()
 Starts the sound from the current playback position.
void stop ()
 Stops playback and resets the playback position.
void pause ()
 Pauses the sound playback.
void setTransform (const MatrixF &transform)
 Sets the position and orientation for a 3d buffer.
void setVelocity (const VectorF &velocity)
 Sets the velocity for a 3d buffer.
void setMinMaxDistance (F32 min, F32 max)
 Sets the minimum and maximum distances for 3d falloff.
void setCone (F32 innerAngle, F32 outerAngle, F32 outerVolume)
 Set sound cone of a 3D sound.
void setVolume (F32 volume)
 Sets the source volume which will still be scaled by the master and channel volumes.
void setPitch (F32 pitch)
 Sets the source pitch scale.
const VectorFgetVelocity () const
 Returns the last set velocity.
const MatrixFgetTransform () const
 Returns the last set transform.
F32 getVolume () const
 Returns the source volume.
F32 getAttenuatedVolume () const
 Returns the volume with respect to the master and channel volumes and the listener.
F32 getPitch () const
 Returns the source pitch scale.
SFXStatus getLastStatus () const
 Returns the last known status without checking the voice or doing the virtual calculation.
SFXStatus getStatus () const
 Returns the sound status.
bool isPlaying () const
 Returns true if the source is playing.
bool isStopped () const
 Returns true if the source is stopped.
bool isPaused () const
 Returns true if the source has been paused.
bool is3d () const
 Returns true if this is a 3D source.
bool isLooping () const
 Returns true if this is a looping source.
U32 getChannel () const
 Returns the volume channel this source is assigned to.
F32 getDistToListener () const
 Returns the last distance to the listener.

Static Public Member Functions

static void initPersistFields ()
 Also needed by IMPLEMENT_CONOBJECT, but we don't use it.

Protected Member Functions

 SFXSource (const SFXProfile *profile)
 Internal constructor used for sources.
virtual ~SFXSource ()
 You cannot delete a source directly.
void _updateVolume (const MatrixF &listener)
 This is called only from the device to allow the source to update it's attenuated volume.
SFXStatus _updateStatus ()
 Called by the device so that the source can update itself and any attached buffer.
bool processArguments (S32 argc, const char **argv)
 We overload this to disable creation of a source via script 'new'.
bool _setStatus (SFXStatus status)
 Used internally for setting the sound status.
void _setModulativeVolume (F32 volume)
 This is called from SFXSystem for setting the volume scalar generated from the master and channel volumes.
bool _allocVoice (SFXDevice *device)
 Create a new voice for this source.
void _freeVoice (SFXDevice *device)
 Release the voice if the source has one.
void onRemove ()
 Overloaed from SimObject to do cleanup.

Static Protected Member Functions

static SFXSource_create (const SFXProfile *profile)
 Used by SFXSystem to create sources.

Protected Attributes

SFXStatus mStatus
 The last updated playback status of the source.
U32 mPlayTime
 The time that playback started.
U32 mPauseTime
 The playback time when we paused or zero.
SimObjectPtr< SFXProfilemProfile
 The profile used to create this source.
WeakRefPtr< SFXVoicemVoice
 The device specific voice which is used during playback.
F32 mAttenuatedVolume
 This is the volume of a source with respect to the last listener position.
F32 mDistToListener
 The distance of this source to the last listener position.
F32 mVolume
 The desired sound volume.
F32 mModulativeVolume
 This.
F32 mPitch
 The sound pitch scalar.
MatrixF mTransform
 The transform if this is a 3d source.
VectorF mVelocity
 The last set velocity.
bool mIs3D
bool mIsLooping
bool mIsStreaming
F32 mMinDistance
F32 mMaxDistance
F32 mConeInsideAngle
 In radians.
F32 mConeOutsideAngle
 In radians.
F32 mConeOutsideVolume
U32 mChannel
StringTableEntry mStatusCallback

Private Types

typedef SimObject Parent

Friends

class SFXSystem
class SFXListener


Member Typedef Documentation

typedef SimObject SFXSource::Parent [private]

Reimplemented from SimObject.


Constructor & Destructor Documentation

SFXSource::SFXSource ( const SFXProfile profile  )  [protected]

Internal constructor used for sources.

virtual SFXSource::~SFXSource (  )  [protected, virtual]

You cannot delete a source directly.

See also:
SFX_DELETE

SFXSource::SFXSource (  )  [explicit]

The default constructor is *only* here to satisfy the construction needs of IMPLEMENT_CONOBJECT.

It does not create a valid source!


Member Function Documentation

static SFXSource* SFXSource::_create ( const SFXProfile profile  )  [static, protected]

Used by SFXSystem to create sources.

void SFXSource::_updateVolume ( const MatrixF listener  )  [protected]

This is called only from the device to allow the source to update it's attenuated volume.

SFXStatus SFXSource::_updateStatus (  )  [protected]

Called by the device so that the source can update itself and any attached buffer.

bool SFXSource::processArguments ( S32  argc,
const char **  argv 
) [protected, virtual]

We overload this to disable creation of a source via script 'new'.

Reimplemented from SimObject.

bool SFXSource::_setStatus ( SFXStatus  status  )  [protected]

Used internally for setting the sound status.

void SFXSource::_setModulativeVolume ( F32  volume  )  [protected]

This is called from SFXSystem for setting the volume scalar generated from the master and channel volumes.

bool SFXSource::_allocVoice ( SFXDevice device  )  [protected]

Create a new voice for this source.

void SFXSource::_freeVoice ( SFXDevice device  )  [protected]

Release the voice if the source has one.

void SFXSource::onRemove (  )  [protected, virtual]

Overloaed from SimObject to do cleanup.

Reimplemented from SimObject.

SFXSource::DECLARE_CONOBJECT ( SFXSource   ) 

static void SFXSource::initPersistFields (  )  [static]

Also needed by IMPLEMENT_CONOBJECT, but we don't use it.

Reimplemented from SimObject.

bool SFXSource::hasVoice (  )  const [inline]

This is normally called from the system to detect if this source has been assigned a voice for playback.

void SFXSource::play (  ) 

Starts the sound from the current playback position.

void SFXSource::stop (  ) 

Stops playback and resets the playback position.

void SFXSource::pause (  ) 

Pauses the sound playback.

void SFXSource::setTransform ( const MatrixF transform  ) 

Sets the position and orientation for a 3d buffer.

void SFXSource::setVelocity ( const VectorF velocity  ) 

Sets the velocity for a 3d buffer.

void SFXSource::setMinMaxDistance ( F32  min,
F32  max 
)

Sets the minimum and maximum distances for 3d falloff.

void SFXSource::setCone ( F32  innerAngle,
F32  outerAngle,
F32  outerVolume 
)

Set sound cone of a 3D sound.

void SFXSource::setVolume ( F32  volume  ) 

Sets the source volume which will still be scaled by the master and channel volumes.

void SFXSource::setPitch ( F32  pitch  ) 

Sets the source pitch scale.

const VectorF& SFXSource::getVelocity (  )  const [inline]

Returns the last set velocity.

const MatrixF& SFXSource::getTransform (  )  const [inline]

Returns the last set transform.

F32 SFXSource::getVolume (  )  const [inline]

Returns the source volume.

F32 SFXSource::getAttenuatedVolume (  )  const [inline]

Returns the volume with respect to the master and channel volumes and the listener.

F32 SFXSource::getPitch (  )  const [inline]

Returns the source pitch scale.

SFXStatus SFXSource::getLastStatus (  )  const [inline]

Returns the last known status without checking the voice or doing the virtual calculation.

SFXStatus SFXSource::getStatus (  )  const [inline]

Returns the sound status.

bool SFXSource::isPlaying (  )  const [inline]

Returns true if the source is playing.

bool SFXSource::isStopped (  )  const [inline]

Returns true if the source is stopped.

bool SFXSource::isPaused (  )  const [inline]

Returns true if the source has been paused.

bool SFXSource::is3d (  )  const [inline]

Returns true if this is a 3D source.

bool SFXSource::isLooping (  )  const [inline]

Returns true if this is a looping source.

U32 SFXSource::getChannel (  )  const [inline]

Returns the volume channel this source is assigned to.

F32 SFXSource::getDistToListener (  )  const [inline]

Returns the last distance to the listener.


Friends And Related Function Documentation

friend class SFXSystem [friend]

friend class SFXListener [friend]


Member Data Documentation

SFXStatus SFXSource::mStatus [mutable, protected]

The last updated playback status of the source.

The time that playback started.

The playback time when we paused or zero.

The profile used to create this source.

The device specific voice which is used during playback.

By making it a SafePtr it will NULL automatically when the device is deleted.

This is the volume of a source with respect to the last listener position.

It is used for culling sounds.

The distance of this source to the last listener position.

F32 SFXSource::mVolume [protected]

The desired sound volume.

This.

F32 SFXSource::mPitch [protected]

The sound pitch scalar.

The transform if this is a 3d source.

The last set velocity.

bool SFXSource::mIs3D [protected]

In radians.

In radians.

U32 SFXSource::mChannel [protected]