cAudio  2.3.0
3d Audio Engine
Public Member Functions | List of all members
cAudio::IAudioSource Class Referenceabstract

Interface for a single audio source, which allow you to manipulate sound sources (speakers) in 2D or 3D space. More...

#include <IAudioSource.h>

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

Public Member Functions

virtual bool play ()=0
 Plays the source with the last set parameters. More...
 
virtual bool play2d (const bool &toLoop=false)=0
 Plays the source in 2D mode. More...
 
virtual bool play3d (const cVector3 &position, const float &soundstr=1.0, const bool &toLoop=false)=0
 Plays the source in 3D mode. More...
 
virtual void pause ()=0
 Pauses playback of the sound source.
 
virtual void stop ()=0
 Stops playback of the sound source.
 
virtual void loop (const bool &toLoop)=0
 Controls whether the source should loop or not. More...
 
virtual bool seek (const float &seconds, bool relative=false)=0
 Seeks through the audio stream to a specific spot. More...
 
virtual bool setBuffer (IAudioBuffer *buffer)=0
 Change the audio buffer associated with the source. More...
 
virtual IAudioBuffergetBuffer ()=0
 Get the audio buffer associated with the source. More...
 
virtual float getTotalAudioTime ()=0
 Returns the total amount of time in the audio stream. See IAudioDecoder for details.
 
virtual int getTotalAudioSize ()=0
 Returns the total decoded size of the audio stream. See IAudioDecoder for details.
 
virtual int getCompressedAudioSize ()=0
 Returns the original size of the audio stream. See IAudioDecoder for details.
 
virtual float getCurrentAudioTime ()=0
 Returns the current position in the audio stream in seconds. See IAudioDecoder for details.
 
virtual int getCurrentAudioPosition ()=0
 Returns the current position in the decoded audio stream in bytes. See IAudioDecoder for details.
 
virtual int getCurrentCompressedAudioPosition ()=0
 Returns the current position in the original audio stream in bytes. See IAudioDecoder for details.
 
virtual bool update ()=0
 Normally called every frame by the audio manager to update the internal buffers. Note: For internal use only.
 
virtual bool isValid () const =0
 Returns if the source is ready to be used.
 
virtual bool isPlaying () const =0
 Returns if the source is playing.
 
virtual bool isPaused () const =0
 Returns if the source is paused.
 
virtual bool isStopped () const =0
 Returns if the source is stopped.
 
virtual bool isLooping () const =0
 Returns if the source is looping.
 
virtual void setPosition (const cVector3 &position)=0
 Sets the position of the source in 3D space. More...
 
virtual void setVelocity (const cVector3 &velocity)=0
 Sets the current velocity of the source for doppler effects. More...
 
virtual void setDirection (const cVector3 &direction)=0
 Sets the direction the source is facing. More...
 
virtual void setRolloffFactor (const float &rolloff)=0
 Sets the factor used in attenuating the source over distance. More...
 
virtual void setStrength (const float &soundstrength)=0
 Sets how well the source carries over distance. More...
 
virtual void setMinDistance (const float &minDistance)=0
 Sets the distance from the source where attenuation will begin. More...
 
virtual void setMaxAttenuationDistance (const float &maxDistance)=0
 Sets the distance from the source where attenuation will stop. More...
 
virtual void setPitch (const float &pitch)=0
 Sets the pitch of the source. More...
 
virtual void setVolume (const float &volume)=0
 Sets the source volume before attenuation and other effects. More...
 
virtual void setMinVolume (const float &minVolume)=0
 Sets the minimum volume that the source can be attenuated to. More...
 
virtual void setMaxVolume (const float &maxVolume)=0
 Sets the maximum volume that the source can achieve. More...
 
virtual void setInnerConeAngle (const float &innerAngle)=0
 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)=0
 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)=0
 Sets how much the volume of the source is scaled in the outer cone. More...
 
virtual void setDopplerStrength (const float &dstrength)=0
 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 cVector3 &dvelocity)=0
 Overrides the doppler velocity vector. It is usually better to let the engine take care of it automatically. More...
 
virtual void move (const cVector3 &position)=0
 Convenience function to automatically set the velocity and position for you in a single call. More...
 
virtual cVector3 getPosition () const =0
 Returns the audio objects position.
 
virtual cVector3 getVelocity () const =0
 Returns the audio objects velocity.
 
virtual cVector3 getDirection () const =0
 Returns the audio objects direction.
 
virtual float getRolloffFactor () const =0
 Returns the factor used in attenuating the source over distance.
 
virtual float getStrength () const =0
 Returns the strength of the source.
 
virtual float getMinDistance () const =0
 Returns the distance from the source where attenuation will begin.
 
virtual float getMaxDistance () const =0
 Returns the distance from the source where attenuation will stop.
 
virtual bool isRelative () const =0
 Return true for 2d sounds, false for 3d sounds.
 
virtual float calculateGain () const =0
 Return gain, taking into account volume as well as distance attenuation.
 
virtual float getPitch () const =0
 Returns the pitch of the source.
 
virtual float getVolume () const =0
 Returns the source volume before attenuation and other effects.
 
virtual float getMinVolume () const =0
 Returns the minimum volume that the source can be attenuated to.
 
virtual float getMaxVolume () const =0
 Returns the maximum volume that the source can achieve.
 
virtual float getInnerConeAngle () const =0
 Returns the angle of the inner sound cone of the source.
 
virtual float getOuterConeAngle () const =0
 Returns the angle of the outer sound cone of the source.
 
virtual float getOuterConeVolume () const =0
 Returns how much the volume of the source is scaled in the outer cone.
 
virtual float getDopplerStrength () const =0
 Returns the doppler strength, which enhances or diminishes the doppler effect.
 
virtual cVector3 getDopplerVelocity () const =0
 Returns the override for the doppler velocity vector.
 
virtual void registerEventHandler (ISourceEventHandler *handler)=0
 Registers a new event handler to this source. More...
 
virtual void unRegisterEventHandler (ISourceEventHandler *handler)=0
 Removes a specified event handler from this source. More...
 
virtual void unRegisterAllEventHandlers ()=0
 Removes all event handlers attached to this source.
 
- Public Member Functions inherited from cAudio::IRefCounted
virtual void grab ()
 Increments the reference count by one.
 
virtual bool drop ()
 Decrements the reference count by one. If it hits zero, this object is deleted.
 
int getReferenceCount () const
 Returns the current reference count of this object.
 

Additional Inherited Members

- Protected Attributes inherited from cAudio::IRefCounted
int RefCount
 

Detailed Description

Interface for a single audio source, which allow you to manipulate sound sources (speakers) in 2D or 3D space.

Definition at line 32 of file IAudioSource.h.

Member Function Documentation

◆ getBuffer()

virtual IAudioBuffer* cAudio::IAudioSource::getBuffer ( )
pure virtual

Get the audio buffer associated with the source.

Returns
buffer on succes, NULL if no buffer or sample is streaming

Implemented in cAudio::cAudioSource, and cAudio::cAudioStaticSource.

◆ loop()

virtual void cAudio::IAudioSource::loop ( const bool &  toLoop)
pure virtual

Controls whether the source should loop or not.

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

Implemented in cAudio::cAudioStaticSource, and cAudio::cAudioSource.

◆ move()

virtual void cAudio::IAudioSource::move ( const cVector3 position)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ play()

virtual bool cAudio::IAudioSource::play ( )
pure virtual

Plays the source with the last set parameters.

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

Implemented in cAudio::cAudioStaticSource, and cAudio::cAudioSource.

◆ play2d()

virtual bool cAudio::IAudioSource::play2d ( const bool &  toLoop = false)
pure 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.

Implemented in cAudio::cAudioStaticSource, and cAudio::cAudioSource.

Here is the caller graph for this function:

◆ play3d()

virtual bool cAudio::IAudioSource::play3d ( const cVector3 position,
const float &  soundstr = 1.0,
const bool &  toLoop = false 
)
pure 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.

Implemented in cAudio::cAudioStaticSource, and cAudio::cAudioSource.

Here is the caller graph for this function:

◆ registerEventHandler()

virtual void cAudio::IAudioSource::registerEventHandler ( ISourceEventHandler handler)
pure virtual

Registers a new event handler to this source.

Parameters
handlerPointer to the event handler to register.

Implemented in cAudio::cAudioSourceBase.

◆ seek()

virtual bool cAudio::IAudioSource::seek ( const float &  seconds,
bool  relative = false 
)
pure 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.

Implemented in cAudio::cAudioStaticSource, and cAudio::cAudioSource.

◆ setBuffer()

virtual bool cAudio::IAudioSource::setBuffer ( IAudioBuffer buffer)
pure virtual

Change the audio buffer associated with the source.

Note: Only supported on sources created with createFromBuffer() or createForBuffer()

Returns
True on success, False if the sample does not support setting buffers or is currently playing

Implemented in cAudio::cAudioSource, and cAudio::cAudioStaticSource.

◆ setDirection()

virtual void cAudio::IAudioSource::setDirection ( const cVector3 direction)
pure virtual

Sets the direction the source is facing.

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

Implemented in cAudio::cAudioSourceBase.

◆ setDopplerStrength()

virtual void cAudio::IAudioSource::setDopplerStrength ( const float &  dstrength)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ setDopplerVelocity()

virtual void cAudio::IAudioSource::setDopplerVelocity ( const cVector3 dvelocity)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ setInnerConeAngle()

virtual void cAudio::IAudioSource::setInnerConeAngle ( const float &  innerAngle)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ setMaxAttenuationDistance()

virtual void cAudio::IAudioSource::setMaxAttenuationDistance ( const float &  maxDistance)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ setMaxVolume()

virtual void cAudio::IAudioSource::setMaxVolume ( const float &  maxVolume)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ setMinDistance()

virtual void cAudio::IAudioSource::setMinDistance ( const float &  minDistance)
pure virtual

Sets the distance from the source where attenuation will begin.

Range: 0.0f to +inf

Parameters
minDistanceDistance from the source where attenuation begins.

Implemented in cAudio::cAudioSourceBase.

◆ setMinVolume()

virtual void cAudio::IAudioSource::setMinVolume ( const float &  minVolume)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ setOuterConeAngle()

virtual void cAudio::IAudioSource::setOuterConeAngle ( const float &  outerAngle)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ setOuterConeVolume()

virtual void cAudio::IAudioSource::setOuterConeVolume ( const float &  outerVolume)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ setPitch()

virtual void cAudio::IAudioSource::setPitch ( const float &  pitch)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ setPosition()

virtual void cAudio::IAudioSource::setPosition ( const cVector3 position)
pure virtual

Sets the position of the source in 3D space.

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

Implemented in cAudio::cAudioSourceBase.

◆ setRolloffFactor()

virtual void cAudio::IAudioSource::setRolloffFactor ( const float &  rolloff)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ setStrength()

virtual void cAudio::IAudioSource::setStrength ( const float &  soundstrength)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ setVelocity()

virtual void cAudio::IAudioSource::setVelocity ( const cVector3 velocity)
pure 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.

Implemented in cAudio::cAudioSourceBase.

◆ setVolume()

virtual void cAudio::IAudioSource::setVolume ( const float &  volume)
pure virtual

Sets the source volume before attenuation and other effects.

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

Parameters
volumeNew volume of the source.

Implemented in cAudio::cAudioSourceBase.

◆ unRegisterEventHandler()

virtual void cAudio::IAudioSource::unRegisterEventHandler ( ISourceEventHandler handler)
pure virtual

Removes a specified event handler from this source.

Parameters
handlerPointer to the event handler to remove.

Implemented in cAudio::cAudioSourceBase.


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