chai3d::cAudioSource Class Reference

This class implements an audio source. More...

#include <CAudioSource.h>

Public Member Functions

 cAudioSource ()
 Constructor of cAudioSource. More...
 
virtual ~cAudioSource ()
 Destructor of cAudioSource. More...
 
bool setAudioBuffer (cAudioBuffer *a_audioBuffer)
 This method sets the audio buffer. More...
 
cAudioBuffergetAudioBuffer ()
 This method returns the audio buffer. More...
 
bool play ()
 This method plays the audio buffer. More...
 
bool isPlaying ()
 This method returns true if the audio source is currently playing, false otherwise. More...
 
bool pause ()
 This method pauses the audio source from playing. More...
 
bool stop ()
 This method stops the audio source from playing. More...
 
bool rewind ()
 This method rewinds the audio source. More...
 
bool setPosTime (const float a_time)
 This method set the current playing position of the audio buffer. More...
 
float getPosTime ()
 This method returns the current playing position on audio buffer. More...
 
short getSampleLeft (double a_time)
 
short getSampleRight (double a_time)
 
bool setPitch (const float a_pitch)
 This method sets the audio pitch. The default value is 1.0. More...
 
float getPitch ()
 This method returns the audio pitch value. More...
 
bool setGain (const float a_gain)
 This method sets the audio gain value. Set value to 0.0 to disable sound. More...
 
float getGain ()
 This method returns the audio gain value. More...
 
bool setSourcePos (const cVector3d a_sourcePos)
 This method sets the position of the audio source in world coordinates. More...
 
cVector3d getSourcePos ()
 This method returns the position of the audio source in world coordinates. More...
 
bool setSourceVel (const cVector3d a_sourceVel)
 This method sets the velocity of the audio source in world coordinates. More...
 
cVector3d getSourceVel ()
 This method returns the velocity of the audio source in world coordinates. More...
 
bool setLoop (const bool a_loop)
 This method enables or disables loop playing. More...
 
bool getLoop ()
 This method returns the status of loop playing. More...
 

Protected Member Functions

bool checkError ()
 This method checks for any OpenAL errors. More...
 

Protected Attributes

unsigned int m_source
 OpenAL audio source ID. More...
 
float m_pitch
 Audio pitch value. More...
 
float m_gain
 Audio gain value. More...
 
cVector3d m_sourcePos
 Position of source in world coordinates. More...
 
cVector3d m_sourceVel
 Velocity of source in world coordinates. More...
 
bool m_loop
 Loop playing mode. More...
 
cAudioBufferm_audioBuffer
 Audio buffer. More...
 

Detailed Description

This class implements an audio source. An audio source is a sound generator that is placed inside the world at a specific location. A sound generator plays sounds that are stored by audio buffers.

Constructor & Destructor Documentation

chai3d::cAudioSource::cAudioSource ( )

Constructor of cAudioSource.

chai3d::cAudioSource::~cAudioSource ( )
virtual

Destructor of cAudioSource.

Member Function Documentation

bool chai3d::cAudioSource::setAudioBuffer ( cAudioBuffer a_audioBuffer)

This method assigns an audio buffer to this audio source.

Returns
true if operation succeeds, false otherwise.
cAudioBuffer* chai3d::cAudioSource::getAudioBuffer ( )
inline
bool chai3d::cAudioSource::play ( )

This method begins playing the audio source.

Returns
true if operation succeeds, false otherwise.
bool chai3d::cAudioSource::isPlaying ( )

This method checks if the audio source is currently playing.

Returns
true if audio source is playing, false otherwise.
bool chai3d::cAudioSource::pause ( )

This method pauses the audio source from playing.

Returns
true if operation succeeds, false otherwise.
bool chai3d::cAudioSource::stop ( )

This method stops the audio source from playing.

Returns
true if operation succeeds, false otherwise.
bool chai3d::cAudioSource::rewind ( )

This method rewinds the audio source.

Returns
true if operation succeeds, false otherwise.
bool chai3d::cAudioSource::setPosTime ( const float  a_time)

This method sets the playing position of the audio source to a desired value a_time passed as argument and defined in seconds.

Parameters
a_timePlaying position defined in seconds.
Returns
true if operation succeeds, false otherwise.
ALfloat chai3d::cAudioSource::getPosTime ( )

This method returns the current playing position of the audio source.

Returns
Current playing position time in seconds.
short chai3d::cAudioSource::getSampleLeft ( double  a_time)

This method returns the left sample at a given time.

Parameters
a_timeSample time.
Returns
Current playing position time in seconds.
short chai3d::cAudioSource::getSampleRight ( double  a_time)

This method returns the right sample at a given time.

Parameters
a_timeSample time.
Returns
Current playing position time in seconds.
bool chai3d::cAudioSource::setPitch ( const float  a_pitch)

This method sets the audio pitch.

Parameters
a_pitchPitch value. This value must be positive.
Returns
true if operation succeeds, false otherwise.
float chai3d::cAudioSource::getPitch ( )
inline
bool chai3d::cAudioSource::setGain ( const float  a_gain)

This method sets the audio gain.

Parameters
a_gainGain value. The value must be positive.
Returns
true if operation succeeds, false otherwise.
float chai3d::cAudioSource::getGain ( )
inline
bool chai3d::cAudioSource::setSourcePos ( const cVector3d  a_sourcePos)

This method sets the position of the audio source in world coordinates.

Parameters
a_sourcePosPosition of the audio source in world coordinates.
Returns
true if operation succeeds, false otherwise.
cVector3d chai3d::cAudioSource::getSourcePos ( )
inline
bool chai3d::cAudioSource::setSourceVel ( const cVector3d  a_sourceVel)

This method sets the velocity of the audio source in world coordinates.

Parameters
a_sourceVelVelocity of the audio source in world coordinates.
Returns
true if operation succeeds, false otherwise.
cVector3d chai3d::cAudioSource::getSourceVel ( )
inline
bool chai3d::cAudioSource::setLoop ( const bool  a_loop)

This method enables or disables loop playing. Set argument a_loop to true to enable loop playing, false otherwise.

Parameters
a_loopLoop playing mode.
Returns
true if operation succeeds, false otherwise.
bool chai3d::cAudioSource::getLoop ( )
inline
bool chai3d::cAudioSource::checkError ( )
protected

This method checks for any OpenAL errors.

Returns
true if no errors occurred, false otherwise.

Member Data Documentation

unsigned int chai3d::cAudioSource::m_source
protected
float chai3d::cAudioSource::m_pitch
protected
float chai3d::cAudioSource::m_gain
protected
cVector3d chai3d::cAudioSource::m_sourcePos
protected
cVector3d chai3d::cAudioSource::m_sourceVel
protected
bool chai3d::cAudioSource::m_loop
protected
cAudioBuffer* chai3d::cAudioSource::m_audioBuffer
protected

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