SFXProfile Class Reference

#include <sfxProfile.h>

Inheritance diagram for SFXProfile:

Inheritance graph
[legend]
List of all members.

Detailed Description

The SFXProfile is used to define a sound for playback.

A few tips:

Make sure each of the defined SFXProfile's fileName doesn't specify an extension. An extension does not need to be specified and by not explicitly saying .ogg or .wav it will allow you to change from one format to the other without having to change the scripts.

Make sure that server SFXProfiles are defined with the datablock keyword, and that client SFXProfiles are defined with the 'new' keyword.

Make sure SFXDescriptions exist for your SFXProfiles. Also make sure that SFXDescriptions are defined BEFORE SFXProfiles. This is especially important if your SFXProfiles are located in different files than your SFXDescriptions. In this case, make sure the files containing SFXDescriptions are exec'd before the files containing the SFXProfiles.


Public Member Functions

 SFXProfile ()
 This is only here to allow DECLARE_CONOBJECT to create us from script.
 SFXProfile (SFXDescription *desc, StringTableEntry filename=NULL, bool preload=false)
 The constructor.
virtual ~SFXProfile ()
 The destructor.
 DECLARE_CONOBJECT (SFXProfile)
bool onAdd ()
 Called when the object is added to the sim.
void onRemove ()
 Called when the object is removed from the sim.
void packData (BitStream *stream)
void unpackData (BitStream *stream)
const char * getFilename () const
 Returns the sound filename.
bool preload (bool server, String &errorStr)
SFXDescriptiongetDescription () const
 Returns the description object for this sound profile.
const ResourceOld< SFXResource > & getResource ()
 Returns the sound resource loading it from disk if it hasn't been preloaded.
SFXBuffergetBuffer ()
 Returns the device buffer for this for this sound.
U32 getSoundDuration ()
 Gets the sound duration in milliseconds or returns 0 if the resource was not found.

Static Public Member Functions

static void initPersistFields ()
 Register dynamic fields in a subclass of ConsoleObject.

Protected Types

typedef SimDataBlock Parent

Protected Member Functions

bool _preloadBuffer ()
 Called when the buffer needs to be preloaded.
void _onDeviceEvent (SFXDevice *device, SFXDeviceEventType evt)
 Callback for device events.

Protected Attributes

S32 mDescriptionId
 Used on the client side during onAdd.
ResourceOld< SFXResourcemResource
 The sound data.
SFXDescriptionmDescription
 The description which controls playback settings.
StringTableEntry mFilename
 The sound filename.
bool mPreload
 If true the sound data will be loaded from disk and possibly cached with the active device before the first call for playback.
WeakRefPtr< SFXBuffermBuffer
 The device specific data buffer.

Friends

class SFXEmitter


Member Typedef Documentation

typedef SimDataBlock SFXProfile::Parent [protected]

Reimplemented from SimDataBlock.


Constructor & Destructor Documentation

SFXProfile::SFXProfile (  )  [explicit]

This is only here to allow DECLARE_CONOBJECT to create us from script.

You shouldn't use this constructor from C++.

SFXProfile::SFXProfile ( SFXDescription desc,
StringTableEntry  filename = NULL,
bool  preload = false 
)

The constructor.

virtual SFXProfile::~SFXProfile (  )  [virtual]

The destructor.


Member Function Documentation

bool SFXProfile::_preloadBuffer (  )  [protected]

Called when the buffer needs to be preloaded.

void SFXProfile::_onDeviceEvent ( SFXDevice device,
SFXDeviceEventType  evt 
) [protected]

Callback for device events.

SFXProfile::DECLARE_CONOBJECT ( SFXProfile   ) 

static void SFXProfile::initPersistFields (  )  [static]

Register dynamic fields in a subclass of ConsoleObject.

See also:
addField(), addFieldV(), addDeprecatedField(), addGroup(), endGroup()

Reimplemented from SimObject.

bool SFXProfile::onAdd (  )  [virtual]

Called when the object is added to the sim.

Reimplemented from SimDataBlock.

void SFXProfile::onRemove (  )  [virtual]

Called when the object is removed from the sim.

Reimplemented from SimObject.

void SFXProfile::packData ( BitStream stream  )  [virtual]

Reimplemented from SimDataBlock.

void SFXProfile::unpackData ( BitStream stream  )  [virtual]

Reimplemented from SimDataBlock.

const char* SFXProfile::getFilename (  )  const [inline]

Returns the sound filename.

bool SFXProfile::preload ( bool  server,
String errorStr 
) [virtual]

Note:
This has nothing to do with mPreload.
See also:
SimDataBlock::preload

Reimplemented from SimDataBlock.

SFXDescription* SFXProfile::getDescription (  )  const [inline]

Returns the description object for this sound profile.

const ResourceOld<SFXResource>& SFXProfile::getResource (  ) 

Returns the sound resource loading it from disk if it hasn't been preloaded.

SFXBuffer* SFXProfile::getBuffer (  ) 

Returns the device buffer for this for this sound.

It will load it from disk if it has not been created already.

U32 SFXProfile::getSoundDuration (  ) 

Gets the sound duration in milliseconds or returns 0 if the resource was not found.


Friends And Related Function Documentation

friend class SFXEmitter [friend]


Member Data Documentation

Used on the client side during onAdd.

The sound data.

The description which controls playback settings.

The sound filename.

If no extension is specified the system will try .wav first then other formats.

If true the sound data will be loaded from disk and possibly cached with the active device before the first call for playback.

The device specific data buffer.