cAudio::cAudioSource Class Reference

Inheritance diagram for cAudio::cAudioSource:
Inheritance graph
[legend]
Collaboration diagram for cAudio::cAudioSource:
Collaboration graph
[legend]

List of all members.

Public Types

enum  Events {
  ON_UPDATE, ON_RELEASE, ON_PLAY, ON_PAUSE,
  ON_STOP
}

Public Member Functions

 cAudioSource (IAudioDecoder *decoder, ALCcontext *context, cEFXFunctions *oALFunctions)
virtual bool play ()
 Plays the source with the last set parameters.
virtual bool play2d (const bool &toLoop=false)
 Plays the source in 2D mode.
virtual bool play3d (const cVector3 &position, const float &soundstr=1.0, const bool &toLoop=false)
 Plays the source in 3D mode.
virtual void pause ()
 Pauses playback of the sound source.
virtual void stop ()
 Stops playback of the sound source.
virtual void loop (const bool &toLoop)
 Controls whether the source should loop or not.
virtual bool seek (const float &seconds, bool relative=false)
 Seeks through the audio stream to a specific spot.
virtual float getTotalAudioTime ()
 Returns the total amount of time in the audio stream. See IAudioDecoder for details.
virtual int getTotalAudioSize ()
 Returns the total decoded size of the audio stream. See IAudioDecoder for details.
virtual int getCompressedAudioSize ()
 Returns the original size of the audio stream. See IAudioDecoder for details.
virtual float getCurrentAudioTime ()
 Returns the current position in the audio stream in seconds. See IAudioDecoder for details.
virtual int getCurrentAudioPosition ()
 Returns the current position in the decoded audio stream in bytes. See IAudioDecoder for details.
virtual int getCurrentCompressedAudioPosition ()
 Returns the current position in the original audio stream in bytes. See IAudioDecoder for details.
virtual bool update ()
 Normally called every frame by the audio manager to update the internal buffers. Note: For internal use only.
virtual void release ()
 Releases all resources used by the audio source, normally used to clean up before deletion. Note: For internal use only.
virtual const bool isValid () const
 Returns if the source is ready to be used.
virtual const bool isPlaying () const
 Returns if the source is playing.
virtual const bool isPaused () const
 Returns if the source is paused.
virtual const bool isStopped () const
 Returns if the source is stopped.
virtual const bool isLooping () const
 Returns if the source is looping.
virtual void setPosition (const cVector3 &position)
 Sets the position of the source in 3D space.
virtual void setVelocity (const cVector3 &velocity)
 Sets the current velocity of the source for doppler effects.
virtual void setDirection (const cVector3 &direction)
 Sets the direction the source is facing.
virtual void setRolloffFactor (const float &rolloff)
 Sets the factor used in attenuating the source over distance.
virtual void setStrength (const float &soundstrength)
 Sets how well the source carries over distance.
virtual void setMinDistance (const float &minDistance)
 Sets the distance from the source where attenuation will begin.
virtual void setMaxDistance (const float &maxDistance)
 Sets the distance from the source where attenuation will stop.
virtual void setPitch (const float &pitch)
 Sets the pitch of the source.
virtual void setVolume (const float &volume)
 Sets the source volume before attenuation and other effects.
virtual void setMinVolume (const float &minVolume)
 Sets the minimum volume that the source can be attenuated to.
virtual void setMaxVolume (const float &maxVolume)
 Sets the maximum volume that the source can achieve.
virtual void setInnerConeAngle (const float &innerAngle)
 Sets the angle of the inner sound cone of the source. The cone opens up in the direction of the source as set by setDirection().
virtual void setOuterConeAngle (const float &outerAngle)
 Sets the angle of the outer sound cone of the source. The cone opens up in the direction of the source as set by setDirection().
virtual void setOuterConeVolume (const float &outerVolume)
 Sets how much the volume of the source is scaled in the outer cone.
virtual void setDopplerStrength (const float &dstrength)
 Sets the doppler strength, which enhances or diminishes the doppler effect. Can be used to exaggerate the doppler for a special effect.
virtual void setDopplerVelocity (const cVector3 &dvelocity)
 Overrides the doppler velocity vector. It is usually better to let the engine take care of it automatically.
virtual void move (const cVector3 &position)
 Convenience function to automatically set the velocity and position for you in a single call.
virtual const cVector3 getPosition () const
 Returns the audio objects position.
virtual const cVector3 getVelocity () const
 Returns the audio objects velocity.
virtual const cVector3 getDirection () const
 Returns the audio objects direction.
virtual const float getRolloffFactor () const
 Returns the factor used in attenuating the source over distance.
virtual const float getStrength () const
 Returns the strength of the source.
virtual const float getMinDistance () const
 Returns the distance from the source where attenuation will begin.
virtual const float getMaxDistance () const
 Returns the distance from the source where attenuation will stop.
virtual const float getPitch () const
 Returns the pitch of the source.
virtual const float getVolume () const
 Returns the source volume before attenuation and other effects.
virtual const float getMinVolume () const
 Returns the minimum volume that the source can be attenuated to.
virtual const float getMaxVolume () const
 Returns the maximum volume that the source can achieve.
virtual const float getInnerConeAngle () const
 Returns the angle of the inner sound cone of the source.
virtual const float getOuterConeAngle () const
 Returns the angle of the outer sound cone of the source.
virtual const float getOuterConeVolume () const
 Returns how much the volume of the source is scaled in the outer cone.
virtual const float getDopplerStrength () const
 Returns the doppler strength, which enhances or diminishes the doppler effect.
virtual const cVector3 getDopplerVelocity () const
 Returns the override for the doppler velocity vector.
virtual void registerEventHandler (ISourceEventHandler *handler)
 Registers a new event handler to this source.
virtual void unRegisterEventHandler (ISourceEventHandler *handler)
 Removes a specified event handler from this source.
virtual void unRegisterAllEventHandlers ()
 Removes all event handlers attached to this source.
virtual unsigned int getNumEffectSlotsAvailable () const
 Returns the number of effects at one time this source can support.
virtual bool attachEffect (unsigned int slot, IEffect *effect)
 Attaches an EFX audio effect to this sound source to a specific slot.
virtual void removeEffect (unsigned int slot)
 Removes an EFX audio effect from this sound source.
virtual bool attachFilter (IFilter *filter)
 Attaches an audio filter to this sound source that will operate on the direct feed, separate from any effects.
virtual void removeFilter ()
 Removes a previously attached filter.

Detailed Description

Definition at line 22 of file cAudioSource.h.


Member Function Documentation

bool cAudio::cAudioSource::attachEffect ( unsigned int  slot,
IEffect effect 
) [virtual]

Attaches an EFX audio effect to this sound source to a specific slot.

Parameters:
slot,: Slot to attach this effect to. Range: 0 to getNumEffectSlotsAvailable().
effect,: Pointer to an effect object to attach.
Returns:
Whether the effect was successfully attached.

Implements cAudio::IAudioSource.

Definition at line 557 of file cAudioSource.cpp.

bool cAudio::cAudioSource::attachFilter ( IFilter filter  )  [virtual]

Attaches an audio filter to this sound source that will operate on the direct feed, separate from any effects.

Parameters:
filter,: Pointer to the filter to attach. Any previous filter will be dropped.
Returns:
Whether the filter was successfully attached.

Implements cAudio::IAudioSource.

Definition at line 587 of file cAudioSource.cpp.

void cAudio::cAudioSource::loop ( const bool &  toLoop  )  [virtual]

Controls whether the source should loop or not.

Parameters:
toLoop,: Whether to loop (restart) the audio when the end is reached.

Implements cAudio::IAudioSource.

Definition at line 166 of file cAudioSource.cpp.

void cAudio::cAudioSource::move ( const cVector3 position  )  [virtual]

Convenience function to automatically set the velocity and position for you in a single call.

Velocity will be set to new position - last position.

Parameters:
position,: Position to move the source to.

Implements cAudio::IAudioSource.

Definition at line 423 of file cAudioSource.cpp.

bool cAudio::cAudioSource::play (  )  [virtual]

Plays the source with the last set parameters.

Returns:
True if the source is playing, false if not.

Implements cAudio::IAudioSource.

Definition at line 85 of file cAudioSource.cpp.

bool cAudio::cAudioSource::play2d ( const bool &  toLoop = false  )  [virtual]

Plays the source in 2D mode.

No automatic attenuation or panning will take place in this mode, but using setPosition will allow you to manually pan mono audio streams.

Parameters:
toLoop,: Whether to loop (restart) the audio when the end is reached.
Returns:
True if the source is playing, false if not.

Implements cAudio::IAudioSource.

Definition at line 122 of file cAudioSource.cpp.

bool cAudio::cAudioSource::play3d ( const cVector3 position,
const float &  soundstr = 1.0,
const bool &  toLoop = false 
) [virtual]

Plays the source in 3D mode.

Parameters:
position,: Position to start the sound off at.
soundstr,: Affects how the source attenuates due to distance. Higher values cause the source to stand out more over distance.
toLoop,: Whether to loop (restart) the audio when the end is reached.
Returns:
True if the source is playing, false if not.

Implements cAudio::IAudioSource.

Definition at line 132 of file cAudioSource.cpp.

void cAudio::cAudioSource::registerEventHandler ( ISourceEventHandler handler  )  [virtual]

Registers a new event handler to this source.

Parameters:
handler,: Pointer to the event handler to register.

Implements cAudio::IAudioSource.

Definition at line 769 of file cAudioSource.cpp.

void cAudio::cAudioSource::removeEffect ( unsigned int  slot  )  [virtual]

Removes an EFX audio effect from this sound source.

Parameters:
slot,: Slot of the effect to remove. Range: 0 to getNumEffectSlotsAvailable().

Implements cAudio::IAudioSource.

Definition at line 573 of file cAudioSource.cpp.

bool cAudio::cAudioSource::seek ( const float &  seconds,
bool  relative = false 
) [virtual]

Seeks through the audio stream to a specific spot.

Note: May not be supported by all codecs.

Parameters:
seconds,: Number of seconds to seek.
relative,: Whether to seek from the current position or the start of the stream.
Returns:
True on success, False if the codec does not support seeking.

Implements cAudio::IAudioSource.

Definition at line 172 of file cAudioSource.cpp.

void cAudio::cAudioSource::setDirection ( const cVector3 direction  )  [virtual]

Sets the direction the source is facing.

Parameters:
direction,: A 3D vector giving the direction that the source is aiming.

Implements cAudio::IAudioSource.

Definition at line 321 of file cAudioSource.cpp.

void cAudio::cAudioSource::setDopplerStrength ( const float &  dstrength  )  [virtual]

Sets the doppler strength, which enhances or diminishes the doppler effect. Can be used to exaggerate the doppler for a special effect.

Range: 0.0f to +inf (Default: 1.0f).

Parameters:
dstrength,: New strength for the doppler effect.

Implements cAudio::IAudioSource.

Definition at line 409 of file cAudioSource.cpp.

void cAudio::cAudioSource::setDopplerVelocity ( const cVector3 dvelocity  )  [virtual]

Overrides the doppler velocity vector. It is usually better to let the engine take care of it automatically.

Note: must be set every time you set the position, velocity, or direction.

Parameters:
dvelocity,: New doppler vector for the source.

Implements cAudio::IAudioSource.

Definition at line 416 of file cAudioSource.cpp.

void cAudio::cAudioSource::setInnerConeAngle ( const float &  innerAngle  )  [virtual]

Sets the angle of the inner sound cone of the source. The cone opens up in the direction of the source as set by setDirection().

Note: This causes the sound to be loudest only if the listener is inside this cone. Range: 0.0f to 360.0f (Default: 360.0f).

Parameters:
innerAngle,: Inside angle of the cone.

Implements cAudio::IAudioSource.

Definition at line 388 of file cAudioSource.cpp.

void cAudio::cAudioSource::setMaxDistance ( const float &  maxDistance  )  [virtual]

Sets the distance from the source where attenuation will stop.

Range: 0.0f to +inf

Parameters:
maxDistance,: Distance where attenuation will cease. Normally the farthest range you can hear the source.

Implements cAudio::IAudioSource.

Definition at line 353 of file cAudioSource.cpp.

void cAudio::cAudioSource::setMaxVolume ( const float &  maxVolume  )  [virtual]

Sets the maximum volume that the source can achieve.

Range: 0.0f to +inf (Default: 1.0f).

Parameters:
maxVolume,: New maximum volume of the source.

Implements cAudio::IAudioSource.

Definition at line 381 of file cAudioSource.cpp.

void cAudio::cAudioSource::setMinDistance ( const float &  minDistance  )  [virtual]

Sets the distance from the source where attenuation will begin.

Range: 0.0f to +inf

Parameters:
minDistance,: Distance from the source where attenuation begins.

Implements cAudio::IAudioSource.

Definition at line 346 of file cAudioSource.cpp.

void cAudio::cAudioSource::setMinVolume ( const float &  minVolume  )  [virtual]

Sets the minimum volume that the source can be attenuated to.

Range: 0.0f to +inf (Default: 0.0f).

Parameters:
minVolume,: New minimum volume of the source.

Implements cAudio::IAudioSource.

Definition at line 374 of file cAudioSource.cpp.

void cAudio::cAudioSource::setOuterConeAngle ( const float &  outerAngle  )  [virtual]

Sets the angle of the outer sound cone of the source. The cone opens up in the direction of the source as set by setDirection().

Note: If the listener is outside of this cone, the sound cannot be heard. Between the inner cone angle and this angle, the sound volume will fall off. Range: 0.0f to 360.0f (Default: 360.0f).

Parameters:
outerAngle,: Outside angle of the cone.

Implements cAudio::IAudioSource.

Definition at line 395 of file cAudioSource.cpp.

void cAudio::cAudioSource::setOuterConeVolume ( const float &  outerVolume  )  [virtual]

Sets how much the volume of the source is scaled in the outer cone.

Range: 0.0f to +inf (Default: 0.0f).

Parameters:
outerVolume,: Volume of the source in the outside cone.

Implements cAudio::IAudioSource.

Definition at line 402 of file cAudioSource.cpp.

void cAudio::cAudioSource::setPitch ( const float &  pitch  )  [virtual]

Sets the pitch of the source.

Range: 0.0f to +inf (Default: 1.0f)

Parameters:
pitch,: New pitch level. Note that higher values will speed up the playback of the sound.

Implements cAudio::IAudioSource.

Definition at line 360 of file cAudioSource.cpp.

void cAudio::cAudioSource::setPosition ( const cVector3 position  )  [virtual]

Sets the position of the source in 3D space.

Parameters:
position,: A 3D vector giving the new location to put this source.

Implements cAudio::IAudioSource.

Definition at line 307 of file cAudioSource.cpp.

void cAudio::cAudioSource::setRolloffFactor ( const float &  rolloff  )  [virtual]

Sets the factor used in attenuating the source over distance.

Larger values make it attenuate faster, smaller values make the source carry better. Range: 0.0f to +inf (Default: 1.0f).

Parameters:
rolloff,: The rolloff factor to apply to the attenuation calculation.

Implements cAudio::IAudioSource.

Definition at line 328 of file cAudioSource.cpp.

void cAudio::cAudioSource::setStrength ( const float &  soundstrength  )  [virtual]

Sets how well the source carries over distance.

Same as setRolloffFactor(1.0f/soundstrength). Range: 0.0f to +inf (Default: 1.0f).

Parameters:
soundstrength,: How well the sound carries over distance.

Implements cAudio::IAudioSource.

Definition at line 335 of file cAudioSource.cpp.

void cAudio::cAudioSource::setVelocity ( const cVector3 velocity  )  [virtual]

Sets the current velocity of the source for doppler effects.

Parameters:
velocity,: A 3D vector giving the speed and direction that the source is moving.

Implements cAudio::IAudioSource.

Definition at line 314 of file cAudioSource.cpp.

void cAudio::cAudioSource::setVolume ( const float &  volume  )  [virtual]

Sets the source volume before attenuation and other effects.

Range: 0.0f to +inf (Default: 1.0f).

Parameters:
volume,: New volume of the source.

Implements cAudio::IAudioSource.

Definition at line 367 of file cAudioSource.cpp.

void cAudio::cAudioSource::unRegisterEventHandler ( ISourceEventHandler handler  )  [virtual]

Removes a specified event handler from this source.

Parameters:
handler,: Pointer to the event handler to remove.

Implements cAudio::IAudioSource.

Definition at line 777 of file cAudioSource.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Enumerations

Generated on Sat Feb 20 22:55:31 2010 for cAudio by  doxygen 1.6.2