SFXProfile

Engine/source/sfx/sfxProfile.h

The SFXProfile is used to define a sound for playback.

More...

Public Types

ChangedSignal 
Parent 

Public Friends

class

Protected Attributes

The device specific data buffer.

The sound filename.

bool

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

The sound data.

Protected Functions

Callback for device events.

bool

Called when the buffer needs to be preloaded.

Public Functions

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

SFXProfile(SFXDescription * desc, const String & filename, bool preload)

The constructor.

The destructor.

Returns the device specific buffer for this for this sound.

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

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

Returns the sound filename.

bool
bool

Called when the object is added to the sim.

Called when the object is removed from the sim.

bool
preload(bool server, String & errorStr)

Public Static Functions

Detailed Description

The SFXProfile is used to define a sound for playback.

An SFXProfile will first try to load its file directly through the SFXDevice. Only if this fails (which is the case for most SFXDevices as these do not implement their own custom sound format loading), the file is loaded through SFXResource.

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.

note:

Live asset update will not work with files loaded directly through the SFXDevice.

Public Types

typedef Signal< void(SFXProfile *) > ChangedSignal 
typedef SFXTrack Parent 

Public Friends

Protected Attributes

StrongWeakRefPtr< SFXBuffer > mBuffer 

The device specific data buffer.

This is only used if for non-streaming sounds.

ChangedSignal mChangedSignal 
String mFilename 

The sound filename.

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

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.

Resource< SFXResource > mResource 

The sound data.

note:

ATM only valid if loaded through SFX's loading system rather than through the SFXDevice's loading system.

Protected Functions

_createBuffer()

_onDeviceEvent(SFXSystemEventType evt)

Callback for device events.

_onResourceChanged(const Torque::Path & path)

_preloadBuffer()

Called when the buffer needs to be preloaded.

_registerSignals()

_unregisterSignals()

Public Functions

SFXProfile()

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

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

SFXProfile(const SFXProfile & , bool )

SFXProfile(SFXDescription * desc, const String & filename, bool preload)

The constructor.

~SFXProfile()

The destructor.

allowSubstitutions()

Reimplemented from: SimObject

cloneAndPerformSubstitutions(const SimObject * , S32 index)

DECLARE_CONOBJECT(SFXProfile )

getBuffer()

Returns the device specific buffer for this for this sound.

If it hasn't been preloaded it will be loaded at this time.

If this is a streaming profile then the buffer returned must be deleted by the caller.

getChangedSignal()

getResource()

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

note:

May be NULL if file is loaded directly through SFXDevice.

getSoundDuration()

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

getSoundFileName()

Returns the sound filename.

isLooping()

onAdd()

Reimplemented from: SFXTrack

onPerformSubstitutions()

Reimplemented from: SimDataBlock

onRemove()

Reimplemented from: SimObject

packData(BitStream * stream)

Reimplemented from: SFXTrack

preload(bool server, String & errorStr)

Reimplemented from: SFXTrack

unpackData(BitStream * stream)

Reimplemented from: SFXTrack

Public Static Functions

initPersistFields()