cAudio
2.3.0
3d Audio Engine
|
Public Types | |
enum | Events { ON_UPDATE, ON_RELEASE, ON_PLAY, ON_PAUSE, ON_STOP } |
Public Member Functions | |
cAudioSourceBase (IAudioDeviceContext *context) | |
virtual bool | isPlaying () const |
Returns if the source is playing. | |
virtual bool | isPaused () const |
Returns if the source is paused. | |
virtual bool | isStopped () const |
Returns if the source is stopped. | |
virtual void | setPosition (const cVector3 &position) |
Sets the position of the source in 3D space. More... | |
virtual void | setVelocity (const cVector3 &velocity) |
Sets the current velocity of the source for doppler effects. More... | |
virtual void | setDirection (const cVector3 &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 | setMaxAttenuationDistance (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 cVector3 &dvelocity) |
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) |
Convenience function to automatically set the velocity and position for you in a single call. More... | |
virtual cVector3 | getPosition () const |
Returns the audio objects position. | |
virtual cVector3 | getVelocity () const |
Returns the audio objects velocity. | |
virtual cVector3 | getDirection () const |
Returns the audio objects direction. | |
virtual float | getRolloffFactor () const |
Returns the factor used in attenuating the source over distance. | |
virtual float | getStrength () const |
Returns the strength of the source. | |
virtual float | getMinDistance () const |
Returns the distance from the source where attenuation will begin. | |
virtual float | getMaxDistance () const |
Returns the distance from the source where attenuation will stop. | |
virtual bool | isRelative () const |
Return true for 2d sounds, false for 3d sounds. | |
virtual float | calculateGain () const |
Return gain, taking into account volume as well as distance attenuation. | |
virtual float | getPitch () const |
Returns the pitch of the source. | |
virtual float | getVolume () const |
Returns the source volume before attenuation and other effects. | |
virtual float | getMinVolume () const |
Returns the minimum volume that the source can be attenuated to. | |
virtual float | getMaxVolume () const |
Returns the maximum volume that the source can achieve. | |
virtual float | getInnerConeAngle () const |
Returns the angle of the inner sound cone of the source. | |
virtual float | getOuterConeAngle () const |
Returns the angle of the outer sound cone of the source. | |
virtual float | getOuterConeVolume () const |
Returns how much the volume of the source is scaled in the outer cone. | |
virtual float | getDopplerStrength () const |
Returns the doppler strength, which enhances or diminishes the doppler effect. | |
virtual cVector3 | getDopplerVelocity () const |
Returns the override for the doppler velocity vector. | |
virtual void | registerEventHandler (ISourceEventHandler *handler) |
Registers a new event handler to this source. More... | |
virtual void | unRegisterEventHandler (ISourceEventHandler *handler) |
Removes a specified event handler from this source. More... | |
virtual void | unRegisterAllEventHandlers () |
Removes all event handlers attached to this source. | |
![]() | |
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 IAudioBuffer * | getBuffer ()=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 | isLooping () const =0 |
Returns if the source is looping. | |
![]() | |
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. | |
![]() | |
void * | operator new (size_t size, const char *file, int line, const char *function) |
void * | operator new (size_t size) |
void * | operator new (size_t size, void *pointer) |
void * | operator new[] (size_t size, const char *file, int line, const char *function) |
void * | operator new[] (size_t size) |
void | operator delete (void *pointer) |
void | operator delete (void *pointer, void *) |
void | operator delete (void *pointer, const char *, int, const char *) |
void | operator delete[] (void *pointer) |
void | operator delete[] (void *pointer, const char *, int, const char *) |
Protected Member Functions | |
void | signalEvent (Events sevent) |
Signals a event to all event handlers. | |
Protected Attributes | |
cAudioMutex | Mutex |
Mutex for thread synchronization. | |
IAudioDeviceContext * | Context |
The context that owns this source. | |
float | Volume |
Holds the current volume. | |
ALuint | Source |
OpenAL source. | |
ALenum | oldState |
cAudioVector< ISourceEventHandler * >::Type | eventHandlerList |
List of registered event handlers. | |
![]() | |
int | RefCount |
Definition at line 24 of file cAudioSource.h.
|
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.
position | Position to move the source to. |
Implements cAudio::IAudioSource.
Definition at line 531 of file cAudioSource.cpp.
|
virtual |
Registers a new event handler to this source.
handler | Pointer to the event handler to register. |
Implements cAudio::IAudioSource.
Definition at line 886 of file cAudioSource.cpp.
|
virtual |
Sets the direction the source is facing.
direction | A 3D vector giving the direction that the source is aiming. |
Implements cAudio::IAudioSource.
Definition at line 428 of file cAudioSource.cpp.
|
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).
dstrength | New strength for the doppler effect. |
Implements cAudio::IAudioSource.
Definition at line 517 of file cAudioSource.cpp.
|
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.
dvelocity | New doppler vector for the source. |
Implements cAudio::IAudioSource.
Definition at line 524 of file cAudioSource.cpp.
|
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).
innerAngle | Inside angle of the cone. |
Implements cAudio::IAudioSource.
Definition at line 496 of file cAudioSource.cpp.
|
virtual |
Sets the distance from the source where attenuation will stop.
Range: 0.0f to +inf
maxDistance | Distance where attenuation will cease. Normally the farthest range you can hear the source. |
Implements cAudio::IAudioSource.
Definition at line 460 of file cAudioSource.cpp.
|
virtual |
Sets the maximum volume that the source can achieve.
Range: 0.0f to +inf (Default: 1.0f).
maxVolume | New maximum volume of the source. |
Implements cAudio::IAudioSource.
Definition at line 489 of file cAudioSource.cpp.
|
virtual |
Sets the distance from the source where attenuation will begin.
Range: 0.0f to +inf
minDistance | Distance from the source where attenuation begins. |
Implements cAudio::IAudioSource.
Definition at line 453 of file cAudioSource.cpp.
|
virtual |
Sets the minimum volume that the source can be attenuated to.
Range: 0.0f to +inf (Default: 0.0f).
minVolume | New minimum volume of the source. |
Implements cAudio::IAudioSource.
Definition at line 482 of file cAudioSource.cpp.
|
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).
outerAngle | Outside angle of the cone. |
Implements cAudio::IAudioSource.
Definition at line 503 of file cAudioSource.cpp.
|
virtual |
Sets how much the volume of the source is scaled in the outer cone.
Range: 0.0f to +inf (Default: 0.0f).
outerVolume | Volume of the source in the outside cone. |
Implements cAudio::IAudioSource.
Definition at line 510 of file cAudioSource.cpp.
|
virtual |
Sets the pitch of the source.
Range: 0.0f to +inf (Default: 1.0f)
pitch | New pitch level. Note that higher values will speed up the playback of the sound. |
Implements cAudio::IAudioSource.
Definition at line 467 of file cAudioSource.cpp.
|
virtual |
Sets the position of the source in 3D space.
position | A 3D vector giving the new location to put this source. |
Implements cAudio::IAudioSource.
Definition at line 414 of file cAudioSource.cpp.
|
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).
rolloff | The rolloff factor to apply to the attenuation calculation. |
Implements cAudio::IAudioSource.
Definition at line 435 of file cAudioSource.cpp.
|
virtual |
Sets how well the source carries over distance.
Same as setRolloffFactor(1.0f/soundstrength). Range: 0.0f to +inf (Default: 1.0f).
soundstrength | How well the sound carries over distance. |
Implements cAudio::IAudioSource.
Definition at line 442 of file cAudioSource.cpp.
|
virtual |
Sets the current velocity of the source for doppler effects.
velocity | A 3D vector giving the speed and direction that the source is moving. |
Implements cAudio::IAudioSource.
Definition at line 421 of file cAudioSource.cpp.
|
virtual |
Sets the source volume before attenuation and other effects.
Range: 0.0f to +inf (Default: 1.0f).
volume | New volume of the source. |
Implements cAudio::IAudioSource.
Definition at line 474 of file cAudioSource.cpp.
|
virtual |
Removes a specified event handler from this source.
handler | Pointer to the event handler to remove. |
Implements cAudio::IAudioSource.
Definition at line 895 of file cAudioSource.cpp.