My Project
Public Types | Public Member Functions | Protected Attributes | List of all members
ParaEngine::CParaSimpleAudioSource Class Reference

represents a single audio file being played or loaded. More...

#include <ParaSimpleAudioSource.h>

Inheritance diagram for ParaEngine::CParaSimpleAudioSource:
ParaEngine::IParaAudioSource

Public Types

enum  AudioFileState { AudioFileState_Ready, AudioFileState_LoadingFromDisk, AudioFileState_NotFound, AudioFileState_Unknown }
 

Public Member Functions

 CParaSimpleAudioSource (const char *sFileName=NULL, unsigned int pSource=0)
 
unsigned int GetSourcePointer ()
 
const std::string & GetFileName ()
 
CParaSimpleAudioSource::AudioFileState GetAudioFileState () const
 
void SetAudioFileState (CParaSimpleAudioSource::AudioFileState val)
 
virtual bool play ()
 Plays the source with the last set parameters. More...
 
virtual bool play2d (const bool &toLoop=false)
 Plays the source in 2D mode. More...
 
virtual bool play3d (const PARAVECTOR3 &position, const float &soundstr=1.0, const bool &toLoop=false)
 Plays the source in 3D mode. More...
 
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. More...
 
virtual bool seek (const float &seconds, bool relative=false)
 Seeks through the audio stream to a specific spot. More...
 
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 PARAVECTOR3 &position)
 Sets the position of the source in 3D space. More...
 
virtual void setVelocity (const PARAVECTOR3 &velocity)
 Sets the current velocity of the source for doppler effects. More...
 
virtual void setDirection (const PARAVECTOR3 &direction)
 Sets the direction the source is facing. More...
 
virtual void setRolloffFactor (const float &rolloff)
 Sets the factor used in attenuating the source over distance. More...
 
virtual void setStrength (const float &soundstrength)
 Sets how well the source carries over distance. More...
 
virtual void setMinDistance (const float &minDistance)
 Sets the distance from the source where attenuation will begin. More...
 
virtual void setMaxDistance (const float &maxDistance)
 Sets the distance from the source where attenuation will stop. More...
 
virtual void setPitch (const float &pitch)
 Sets the pitch of the source. More...
 
virtual void setVolume (const float &volume)
 Sets the source volume before attenuation and other effects. More...
 
virtual void setMinVolume (const float &minVolume)
 Sets the minimum volume that the source can be attenuated to. More...
 
virtual void setMaxVolume (const float &maxVolume)
 Sets the maximum volume that the source can achieve. More...
 
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(). More...
 
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(). More...
 
virtual void setOuterConeVolume (const float &outerVolume)
 Sets how much the volume of the source is scaled in the outer cone. More...
 
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. More...
 
virtual void setDopplerVelocity (const PARAVECTOR3 &dvelocity)
 Overrides the doppler velocity vector. It is usually better to let the engine take care of it automatically. More...
 
virtual void move (const PARAVECTOR3 &position)
 Convenience function to automatically set the velocity and position for you in a single call. More...
 
virtual const PARAVECTOR3 getPosition () const
 Returns the audio objects position.
 
virtual const PARAVECTOR3 getVelocity () const
 Returns the audio objects velocity.
 
virtual const PARAVECTOR3 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 PARAVECTOR3 getDopplerVelocity () const
 Returns the override for the doppler velocity vector.
 
virtual void registerEventHandler (IAudioSourceEventHandler *handler)
 Registers a new event handler to this source. More...
 
virtual void unRegisterAllEventHandlers ()
 Removes all event handlers attached to this source.
 
bool IsBackgroundMusic ()
 only one bg music at a time. More...
 

Protected Attributes

unsigned int m_pSource
 
std::string m_sFilename
 
bool m_bLoop
 
bool m_bPlaying
 
uint32 m_nCurTick
 
AudioFileState m_nAudioFileState
 

Detailed Description

represents a single audio file being played or loaded.

Member Enumeration Documentation

§ AudioFileState

Enumerator
AudioFileState_Ready 

asset is always created in normal state.

Member Function Documentation

§ IsBackgroundMusic()

bool ParaEngine::CParaSimpleAudioSource::IsBackgroundMusic ( )
inline

only one bg music at a time.

we will regard any looping audio as background music.

§ loop()

void ParaEngine::CParaSimpleAudioSource::loop ( const bool &  toLoop)
virtual

Controls whether the source should loop or not.

Parameters
toLoopWhether to loop (restart) the audio when the end is reached.

Implements ParaEngine::IParaAudioSource.

§ move()

void ParaEngine::CParaSimpleAudioSource::move ( const PARAVECTOR3 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
positionPosition to move the source to.

Implements ParaEngine::IParaAudioSource.

§ play()

bool ParaEngine::CParaSimpleAudioSource::play ( )
virtual

Plays the source with the last set parameters.

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

Implements ParaEngine::IParaAudioSource.

§ play2d()

bool ParaEngine::CParaSimpleAudioSource::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
toLoopWhether to loop (restart) the audio when the end is reached.
Returns
True if the source is playing, false if not.

Implements ParaEngine::IParaAudioSource.

§ play3d()

bool ParaEngine::CParaSimpleAudioSource::play3d ( const PARAVECTOR3 position,
const float &  soundstr = 1.0,
const bool &  toLoop = false 
)
virtual

Plays the source in 3D mode.

Parameters
positionPosition to start the sound off at.
soundstrAffects how the source attenuates due to distance. Higher values cause the source to stand out more over distance.
toLoopWhether to loop (restart) the audio when the end is reached.
Returns
True if the source is playing, false if not.

Implements ParaEngine::IParaAudioSource.

§ registerEventHandler()

void ParaEngine::CParaSimpleAudioSource::registerEventHandler ( IAudioSourceEventHandler handler)
virtual

Registers a new event handler to this source.

Parameters
handlerPointer to the event handler to register.

Implements ParaEngine::IParaAudioSource.

§ seek()

bool ParaEngine::CParaSimpleAudioSource::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
secondsNumber of seconds to seek.
relativeWhether 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 ParaEngine::IParaAudioSource.

§ setDirection()

void ParaEngine::CParaSimpleAudioSource::setDirection ( const PARAVECTOR3 direction)
virtual

Sets the direction the source is facing.

Parameters
directionA 3D vector giving the direction that the source is aiming.

Implements ParaEngine::IParaAudioSource.

§ setDopplerStrength()

void ParaEngine::CParaSimpleAudioSource::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
dstrengthNew strength for the doppler effect.

Implements ParaEngine::IParaAudioSource.

§ setDopplerVelocity()

void ParaEngine::CParaSimpleAudioSource::setDopplerVelocity ( const PARAVECTOR3 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
dvelocityNew doppler vector for the source.

Implements ParaEngine::IParaAudioSource.

§ setInnerConeAngle()

void ParaEngine::CParaSimpleAudioSource::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
innerAngleInside angle of the cone.

Implements ParaEngine::IParaAudioSource.

§ setMaxDistance()

void ParaEngine::CParaSimpleAudioSource::setMaxDistance ( const float &  maxDistance)
virtual

Sets the distance from the source where attenuation will stop.

Range: 0.0f to +inf

Parameters
maxDistanceDistance where attenuation will cease. Normally the farthest range you can hear the source.

Implements ParaEngine::IParaAudioSource.

§ setMaxVolume()

void ParaEngine::CParaSimpleAudioSource::setMaxVolume ( const float &  maxVolume)
virtual

Sets the maximum volume that the source can achieve.

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

Parameters
maxVolumeNew maximum volume of the source.

Implements ParaEngine::IParaAudioSource.

§ setMinDistance()

void ParaEngine::CParaSimpleAudioSource::setMinDistance ( const float &  minDistance)
virtual

Sets the distance from the source where attenuation will begin.

Range: 0.0f to +inf

Parameters
minDistanceDistance from the source where attenuation begins.

Implements ParaEngine::IParaAudioSource.

§ setMinVolume()

void ParaEngine::CParaSimpleAudioSource::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
minVolumeNew minimum volume of the source.

Implements ParaEngine::IParaAudioSource.

§ setOuterConeAngle()

void ParaEngine::CParaSimpleAudioSource::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
outerAngleOutside angle of the cone.

Implements ParaEngine::IParaAudioSource.

§ setOuterConeVolume()

void ParaEngine::CParaSimpleAudioSource::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
outerVolumeVolume of the source in the outside cone.

Implements ParaEngine::IParaAudioSource.

§ setPitch()

void ParaEngine::CParaSimpleAudioSource::setPitch ( const float &  pitch)
virtual

Sets the pitch of the source.

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

Parameters
pitchNew pitch level. Note that higher values will speed up the playback of the sound.

Implements ParaEngine::IParaAudioSource.

§ setPosition()

void ParaEngine::CParaSimpleAudioSource::setPosition ( const PARAVECTOR3 position)
virtual

Sets the position of the source in 3D space.

Parameters
positionA 3D vector giving the new location to put this source.

Implements ParaEngine::IParaAudioSource.

§ setRolloffFactor()

void ParaEngine::CParaSimpleAudioSource::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
rolloffThe rolloff factor to apply to the attenuation calculation.

Implements ParaEngine::IParaAudioSource.

§ setStrength()

void ParaEngine::CParaSimpleAudioSource::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
soundstrengthHow well the sound carries over distance.

Implements ParaEngine::IParaAudioSource.

§ setVelocity()

void ParaEngine::CParaSimpleAudioSource::setVelocity ( const PARAVECTOR3 velocity)
virtual

Sets the current velocity of the source for doppler effects.

Parameters
velocityA 3D vector giving the speed and direction that the source is moving.

Implements ParaEngine::IParaAudioSource.

§ setVolume()

void ParaEngine::CParaSimpleAudioSource::setVolume ( const float &  volume)
virtual

Sets the source volume before attenuation and other effects.

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

Parameters
volumeNew volume of the source.

Implements ParaEngine::IParaAudioSource.


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