30e5b4a99e
Added conversion functions from our audio format enum to OpenAL's in preparation for supporting more formats. Reorganized cAudio defines, made it easier to access some compile time parameters. Fixed a bug where a source could not be played again after it reached the end of its audio stream. Added better checking for sources. IsValid() should provide a more useful indication of whether a source is usable. Added error checking and logging to cAudioCapture. Prevented initializing of cAudioManager until shutdown() has been called. Added a tutorial for Audio Effects. Added a footsteps sound for showing off Audio Effects. Moved the default compile location for the main library to lib/. The msvc project will copy the cAudio.dll to bin/win32-visual/
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
#include "../Headers/cListener.h"
|
|
#include <AL/al.h>
|
|
#include "../Headers/cEFXFunctions.h"
|
|
|
|
namespace cAudio
|
|
{
|
|
void cListener::setPosition(const cVector3 pos)
|
|
{
|
|
cAudioMutexBasicLock lock(Mutex);
|
|
Position = pos;
|
|
alListener3f(AL_POSITION, Position.x, Position.y, Position.z);
|
|
}
|
|
void cListener::setDirection(const cVector3 dir)
|
|
{
|
|
cAudioMutexBasicLock lock(Mutex);
|
|
Direction = dir;
|
|
float orient[6] = {Direction[0], Direction[1], Direction[2], UpVector[0], UpVector[1], UpVector[2]};
|
|
alListenerfv(AL_ORIENTATION, orient);
|
|
}
|
|
void cListener::setUpVector(const cVector3 up)
|
|
{
|
|
cAudioMutexBasicLock lock(Mutex);
|
|
UpVector = up;
|
|
float orient[6] = {Direction[0], Direction[1], Direction[2], UpVector[0], UpVector[1], UpVector[2]};
|
|
alListenerfv(AL_ORIENTATION, orient);
|
|
}
|
|
void cListener::setVelocity(const cVector3 vel)
|
|
{
|
|
cAudioMutexBasicLock lock(Mutex);
|
|
Velocity = vel;
|
|
alListener3f(AL_VELOCITY, Velocity.x, Velocity.y, Velocity.z);
|
|
}
|
|
void cListener::setMasterVolume(const float volume)
|
|
{
|
|
cAudioMutexBasicLock lock(Mutex);
|
|
MasterGain = volume;
|
|
alListenerf(AL_GAIN, MasterGain);
|
|
}
|
|
void cListener::move(const cVector3 pos)
|
|
{
|
|
cAudioMutexBasicLock lock(Mutex);
|
|
Velocity = pos - Position;
|
|
Position = pos;
|
|
|
|
alListener3f(AL_POSITION, Position.x, Position.y, Position.z);
|
|
alListener3f(AL_VELOCITY, Velocity.x, Velocity.y, Velocity.z);
|
|
}
|
|
#ifdef CAUDIO_EFX_ENABLED
|
|
//!Sets the meters per user world unit for use with sound effects
|
|
void cListener::setMetersPerUnit(const float& meters)
|
|
{
|
|
cAudioMutexBasicLock lock(Mutex);
|
|
alListenerf(AL_METERS_PER_UNIT, meters);
|
|
}
|
|
|
|
//!Returns the meters per user world unit for use with sound effects
|
|
float cListener::getMetersPerUnit(void) const
|
|
{
|
|
float value = 1.0f;
|
|
alGetListenerf(AL_METERS_PER_UNIT, &value);
|
|
return value;
|
|
}
|
|
#endif
|
|
}; |