Drag[en]gine Game Engine  1.21
deSpeaker Class Reference

Speaker resource. More...

#include <deSpeaker.h>

Inheritance diagram for deSpeaker:
deResource deObject

Public Types

enum  ePlayStates { epsStopped , epsPlaying , epsPaused }
 Play states. More...
 
enum  eSpeakerType { estPoint , estDirected }
 Speaker type. More...
 
typedef deTObjectReference< deSpeakerRef
 Type holding strong reference. More...
 
- Public Types inherited from deResource
typedef deTObjectReference< deResourceRef
 Type holding strong reference. More...
 
- Public Types inherited from deObject
typedef deTObjectReference< deObjectRef
 Type holding strong reference. More...
 

Public Member Functions

Management
eSpeakerType GetType () const
 Type. More...
 
void SetType (eSpeakerType type)
 Set type. More...
 
deSoundGetSound () const
 Sound or NULL if not set. More...
 
void SetSound (deSound *sound)
 Set sound or NULL if not set. More...
 
deSynthesizerInstanceGetSynthesizer () const
 Synthesizer or NULL if not set. More...
 
void SetSynthesizer (deSynthesizerInstance *synthesizer)
 Set synthesizer or NULL if not set. More...
 
deVideoPlayerGetVideoPlayer () const
 Video player or NULL if not set. More...
 
void SetVideoPlayer (deVideoPlayer *videoPlayer)
 Set video player or NULL if not set. More...
 
const decDVectorGetPosition () const
 Position. More...
 
void SetPosition (const decDVector &position)
 Set position. More...
 
const decQuaternionGetOrientation () const
 Orientation. More...
 
void SetOrientation (const decQuaternion &orientation)
 Set orientation. More...
 
const decVectorGetVelocity () const
 Velocity in m/s. More...
 
void SetVelocity (const decVector &velocity)
 Set velocity in m/s. More...
 
bool GetMuted () const
 Speaker is muted. More...
 
void SetMuted (bool muted)
 Set if speaker is muted. More...
 
bool GetLooping () const
 Speaker is playing once or is looping. More...
 
void SetLooping (bool looping)
 Set if speaker is playing once or is looping. More...
 
int GetPlayFrom () const
 Start play position in samples. More...
 
int GetPlayTo () const
 End play position in samples. More...
 
void SetPlayPosition (int playFrom, int playTo)
 Set play position in samples. More...
 
float GetPlaySpeed () const
 Play speed. More...
 
void SetPlaySpeed (float playSpeed)
 Set play speed. More...
 
float GetVolume () const
 Volume. More...
 
void SetVolume (float volume)
 Set volume. More...
 
float GetRange () const
 Range beyond which the sound is inaudible. More...
 
void SetRange (float range)
 Set range beyond which the sound is inaudible. More...
 
float GetRollOff () const
 Roll off factor. More...
 
void SetRollOff (float rollOff)
 Set roll off factor. More...
 
float GetDistanceOffset () const
 Distance offset for attenuation calculation. More...
 
void SetDistanceOffset (float distanceOffset)
 Set distance offset for attenuation calculation. More...
 
const decShapeListGetShape () const
 Sound shape. More...
 
void SetShape (const decShapeList &shape)
 Set sound shape. More...
 
const decLayerMaskGetLayerMask () const
 Layer mask. More...
 
void SetLayerMask (const decLayerMask &layerMask)
 Set layer mask. More...
 
ePlayStates GetPlayState () const
 Play state. More...
 
bool GetPlaying () const
 Speaker is playing. More...
 
bool GetPaused () const
 Speaker is paused. More...
 
bool GetStopped () const
 Speaker is stopped. More...
 
void SetPlayState (ePlayStates playState)
 Set play state. More...
 
void Play ()
 Start playing. More...
 
void Stop ()
 Stop playing. More...
 
void Pause ()
 Pause playing. More...
 
System Peers
deBaseAudioSpeakerGetPeerAudio () const
 Audio system peer or NULL if not set. More...
 
void SetPeerAudio (deBaseAudioSpeaker *peer)
 Set audio system peer or NULL if not set. More...
 
deBaseScriptingSpeakerGetPeerScripting () const
 Scripting system peer. More...
 
void SetPeerScripting (deBaseScriptingSpeaker *peer)
 Set scripting system peer. More...
 
Linked list world
deWorldGetParentWorld () const
 Parent world or NULL. More...
 
void SetParentWorld (deWorld *world)
 Set parent world or NULL. More...
 
deSpeakerGetLLWorldPrev () const
 Previous speaker in the parent world linked list. More...
 
void SetLLWorldPrev (deSpeaker *speaker)
 Set next speaker in the parent world linked list. More...
 
deSpeakerGetLLWorldNext () const
 Next speaker in the parent world linked list. More...
 
void SetLLWorldNext (deSpeaker *speaker)
 Set next speaker in the parent world linked list. More...
 
- Public Member Functions inherited from deResource
deResourceManagerGetResourceManager () const
 Resource manager or NULL if resource is leaking. More...
 
deEngineGetEngine () const
 Game engine object from resource manager. More...
 
deResourceGetLLManagerPrev () const
 Previous resource in the resource manager linked list. More...
 
void SetLLManagerPrev (deResource *resource)
 Set next resource in the resource manager linked list. More...
 
deResourceGetLLManagerNext () const
 Next resource in the resource manager linked list. More...
 
void SetLLManagerNext (deResource *resource)
 Set next resource in the resource manager linked list. More...
 
void MarkLeaking ()
 Marks the resource leaking. More...
 
 deResource (deResourceManager *resourceManager)
 Create resource. More...
 
- Public Member Functions inherited from deObject
int GetRefCount () const
 Reference count. More...
 
void AddReference ()
 Add reference increasing reference count by 1. More...
 
void FreeReference ()
 Decrease reference count by one and delete object if count reaches 0. More...
 
 deObject ()
 Create object with reference count of 1. More...
 

Constructors and Destructors

 deSpeaker (deSpeakerManager *manager)
 Create speaker. More...
 
virtual ~deSpeaker ()
 Clean up speaker object. More...
 

Linked list microphone

deMicrophoneGetParentMicrophone () const
 Parent microphone or NULL. More...
 
void SetParentMicrophone (deMicrophone *microphone)
 Set parent microphone or NULL. More...
 
deSpeakerGetLLMicrophonePrev () const
 Previous speaker in the parent microphone linked list. More...
 
void SetLLMicrophonePrev (deSpeaker *speaker)
 Set next speaker in the parent microphone linked list. More...
 
deSpeakerGetLLMicrophoneNext () const
 Next speaker in the parent microphone linked list. More...
 
void SetLLMicrophoneNext (deSpeaker *speaker)
 Set next speaker in the parent microphone linked list. More...
 

Additional Inherited Members

- Protected Member Functions inherited from deResource
virtual ~deResource ()
 Clean up resource. More...
 
- Protected Member Functions inherited from deObject
virtual ~deObject ()
 Clean up object. More...
 

Detailed Description

Speaker resource.

Defines a sound or music emmiting source in a world similar to a speaker. Every speaker can play a sound file once or in a loop multiple times as well as music. To avoid a lot of adding and removing of speakers they can be muted individually preventing them from emitting sound or music without removing them. Speakers usually act like a point source emitting sound in all directions. Optionally the speaker can be set to be directed like a spot light emitting sound only in one direction.

The range and roll-off factor is used to shape the attenuation of the speaker. The roll-off factor works similar to the Inverse Distance attenuation model. A value of 1 indicates physically realistic behavior. Values above 1 produce stronger attenuation while values less than 1 produce weaker attenuation. Beyond the range the sound becomes fully inaudible. The sound modules ensure the sound is attenuated in a way it reaches 0 at the range boundary. Typically this is done with a linear scaling across the entire range but can be chosen by the audio module to produce best results.

The best way to set these parameters is to start with the default values to get a physically realistic sound attenuation. Then adjust the range to be smaller to reduce the number of speakers affecting the listener at the same time. Doing so usually saves processing time. If the range becomes small it might be required to alter the roll-off to compensate. Usually though there is no need to change the roll-off value.

Member Typedef Documentation

◆ Ref

Type holding strong reference.

Member Enumeration Documentation

◆ ePlayStates

Play states.

Enumerator
epsStopped 

Speaker is not playing back.

epsPlaying 

Speaker is playing back.

epsPaused 

Playback is paused.

◆ eSpeakerType

Speaker type.

Enumerator
estPoint 

Speaker emits equally in all directions.

estDirected 

Speaker emits conically along Z axis.

Constructor & Destructor Documentation

◆ deSpeaker()

deSpeaker::deSpeaker ( deSpeakerManager manager)

Create speaker.

◆ ~deSpeaker()

virtual deSpeaker::~deSpeaker ( )
protectedvirtual

Clean up speaker object.

Note
Subclasses should set their destructor protected too to avoid users accidently deleting a reference counted object through the object pointer. Only FreeReference() is allowed to delete the object.

Member Function Documentation

◆ GetDistanceOffset()

float deSpeaker::GetDistanceOffset ( ) const
inline

Distance offset for attenuation calculation.

Version
1.12

For use by distance sounds. Offsets the true distance to the sound source for attenuation calculation to make the sound appear coming from far away. Requires increasing the volume to compensate for the distance increased attenuation.

◆ GetLayerMask()

const decLayerMask& deSpeaker::GetLayerMask ( ) const
inline

Layer mask.

◆ GetLLMicrophoneNext()

deSpeaker* deSpeaker::GetLLMicrophoneNext ( ) const
inline

Next speaker in the parent microphone linked list.

◆ GetLLMicrophonePrev()

deSpeaker* deSpeaker::GetLLMicrophonePrev ( ) const
inline

Previous speaker in the parent microphone linked list.

◆ GetLLWorldNext()

deSpeaker* deSpeaker::GetLLWorldNext ( ) const
inline

Next speaker in the parent world linked list.

◆ GetLLWorldPrev()

deSpeaker* deSpeaker::GetLLWorldPrev ( ) const
inline

Previous speaker in the parent world linked list.

◆ GetLooping()

bool deSpeaker::GetLooping ( ) const
inline

Speaker is playing once or is looping.

◆ GetMuted()

bool deSpeaker::GetMuted ( ) const
inline

Speaker is muted.

◆ GetOrientation()

const decQuaternion& deSpeaker::GetOrientation ( ) const
inline

Orientation.

◆ GetParentMicrophone()

deMicrophone* deSpeaker::GetParentMicrophone ( ) const
inline

Parent microphone or NULL.

◆ GetParentWorld()

deWorld* deSpeaker::GetParentWorld ( ) const
inline

Parent world or NULL.

◆ GetPaused()

bool deSpeaker::GetPaused ( ) const
inline

Speaker is paused.

◆ GetPeerAudio()

deBaseAudioSpeaker* deSpeaker::GetPeerAudio ( ) const
inline

Audio system peer or NULL if not set.

◆ GetPeerScripting()

deBaseScriptingSpeaker* deSpeaker::GetPeerScripting ( ) const
inline

Scripting system peer.

◆ GetPlayFrom()

int deSpeaker::GetPlayFrom ( ) const
inline

Start play position in samples.

◆ GetPlaying()

bool deSpeaker::GetPlaying ( ) const
inline

Speaker is playing.

◆ GetPlaySpeed()

float deSpeaker::GetPlaySpeed ( ) const
inline

Play speed.

◆ GetPlayState()

ePlayStates deSpeaker::GetPlayState ( ) const
inline

Play state.

◆ GetPlayTo()

int deSpeaker::GetPlayTo ( ) const
inline

End play position in samples.

◆ GetPosition()

const decDVector& deSpeaker::GetPosition ( ) const
inline

Position.

◆ GetRange()

float deSpeaker::GetRange ( ) const
inline

Range beyond which the sound is inaudible.

◆ GetRollOff()

float deSpeaker::GetRollOff ( ) const
inline

Roll off factor.

1 is physically realistic. Larger than 1 applies stronger attenuation. Smaller values apply weaker attenuation.

◆ GetShape()

const decShapeList& deSpeaker::GetShape ( ) const
inline

Sound shape.

◆ GetSound()

deSound* deSpeaker::GetSound ( ) const
inline

Sound or NULL if not set.

◆ GetStopped()

bool deSpeaker::GetStopped ( ) const
inline

Speaker is stopped.

◆ GetSynthesizer()

deSynthesizerInstance* deSpeaker::GetSynthesizer ( ) const
inline

Synthesizer or NULL if not set.

◆ GetType()

eSpeakerType deSpeaker::GetType ( ) const
inline

Type.

◆ GetVelocity()

const decVector& deSpeaker::GetVelocity ( ) const
inline

Velocity in m/s.

◆ GetVideoPlayer()

deVideoPlayer* deSpeaker::GetVideoPlayer ( ) const
inline

Video player or NULL if not set.

◆ GetVolume()

float deSpeaker::GetVolume ( ) const
inline

Volume.

◆ Pause()

void deSpeaker::Pause ( )

Pause playing.

◆ Play()

void deSpeaker::Play ( )

Start playing.

◆ SetDistanceOffset()

void deSpeaker::SetDistanceOffset ( float  distanceOffset)

Set distance offset for attenuation calculation.

Version
1.12

For use by distance sounds. Offsets the true distance to the sound source for attenuation calculation to make the sound appear coming from far away. Requires increasing the volume to compensate for the distance increased attenuation.

◆ SetLayerMask()

void deSpeaker::SetLayerMask ( const decLayerMask layerMask)

Set layer mask.

◆ SetLLMicrophoneNext()

void deSpeaker::SetLLMicrophoneNext ( deSpeaker speaker)

Set next speaker in the parent microphone linked list.

◆ SetLLMicrophonePrev()

void deSpeaker::SetLLMicrophonePrev ( deSpeaker speaker)

Set next speaker in the parent microphone linked list.

◆ SetLLWorldNext()

void deSpeaker::SetLLWorldNext ( deSpeaker speaker)

Set next speaker in the parent world linked list.

◆ SetLLWorldPrev()

void deSpeaker::SetLLWorldPrev ( deSpeaker speaker)

Set next speaker in the parent world linked list.

◆ SetLooping()

void deSpeaker::SetLooping ( bool  looping)

Set if speaker is playing once or is looping.

◆ SetMuted()

void deSpeaker::SetMuted ( bool  muted)

Set if speaker is muted.

◆ SetOrientation()

void deSpeaker::SetOrientation ( const decQuaternion orientation)

Set orientation.

◆ SetParentMicrophone()

void deSpeaker::SetParentMicrophone ( deMicrophone microphone)

Set parent microphone or NULL.

◆ SetParentWorld()

void deSpeaker::SetParentWorld ( deWorld world)

Set parent world or NULL.

◆ SetPeerAudio()

void deSpeaker::SetPeerAudio ( deBaseAudioSpeaker peer)

Set audio system peer or NULL if not set.

◆ SetPeerScripting()

void deSpeaker::SetPeerScripting ( deBaseScriptingSpeaker peer)

Set scripting system peer.

◆ SetPlayPosition()

void deSpeaker::SetPlayPosition ( int  playFrom,
int  playTo 
)

Set play position in samples.

◆ SetPlaySpeed()

void deSpeaker::SetPlaySpeed ( float  playSpeed)

Set play speed.

◆ SetPlayState()

void deSpeaker::SetPlayState ( ePlayStates  playState)

Set play state.

◆ SetPosition()

void deSpeaker::SetPosition ( const decDVector position)

Set position.

◆ SetRange()

void deSpeaker::SetRange ( float  range)

Set range beyond which the sound is inaudible.

◆ SetRollOff()

void deSpeaker::SetRollOff ( float  rollOff)

Set roll off factor.

1 is physically realistic. Larger than 1 applies stronger attenuation. Smaller values apply weaker attenuation.

◆ SetShape()

void deSpeaker::SetShape ( const decShapeList shape)

Set sound shape.

◆ SetSound()

void deSpeaker::SetSound ( deSound sound)

Set sound or NULL if not set.

◆ SetSynthesizer()

void deSpeaker::SetSynthesizer ( deSynthesizerInstance synthesizer)

Set synthesizer or NULL if not set.

◆ SetType()

void deSpeaker::SetType ( eSpeakerType  type)

Set type.

◆ SetVelocity()

void deSpeaker::SetVelocity ( const decVector velocity)

Set velocity in m/s.

◆ SetVideoPlayer()

void deSpeaker::SetVideoPlayer ( deVideoPlayer videoPlayer)

Set video player or NULL if not set.

◆ SetVolume()

void deSpeaker::SetVolume ( float  volume)

Set volume.

◆ Stop()

void deSpeaker::Stop ( )

Stop playing.


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