diff --git a/Headers/cAudio.h b/Headers/cAudio.h index 9cfa62f..7fda928 100644 --- a/Headers/cAudio.h +++ b/Headers/cAudio.h @@ -2,12 +2,14 @@ #define CAUDIO_H_INCLUDED #include #include +#include #include "AL/al.h" #include "AL/alut.h" -#include #define BUFFER_SIZE ( 1024 * 32 ) #include "../include/IAudio.h" +#include "../Include/cVector3.h" + namespace cAudio { class cAudio : public IAudio @@ -18,14 +20,14 @@ namespace cAudio //!plays the audio file 2d no distance. void play2d(bool loop = false); //!plays the audio file and sets it to 3d - void play3d(bool loop = false, float x = 0.0, float y = 0.0, float z = 0.0, float soundstr = 1.0); + void play3d(cVector3 position, float soundstr = 1.0 , bool loop = false); //!allows us to set the position or reset the position - void setPosition(float posx,float posy,float posz); + void setPosition(cVector3 position); //!allows you to set the audio objects velocity - void setVelocity(float velx,float vely,float velz); + void setVelocity(cVector3 velocity); //!allows us to set the direction the audio should play in - void setDirection(float dirx,float diry,float dirz); + void setDirection(cVector3 direction); //! Sets the audios pitch level void setPitch(float pitch); //!allows us to set and reset the sound strenght @@ -35,7 +37,7 @@ namespace cAudio //!Set the doppler strength void setDopplerStrength(float doop); //!Set doppler velocity - void setDopplerVelocity(float doopx,float doopy,float doopz); + void setDopplerVelocity(cVector3 dvelocity); //!Seek the audio stream void seek(float secs); @@ -88,6 +90,14 @@ namespace cAudio bool pauseaudio; //!if audio is paused bool paused(); + //! Stores the position of the audio object + cVector3 position; + //! Stores the velocity of the audio object + cVector3 velocity; + //! Stores the direction of the audio object + cVector3 direction; + //! Stores the doppler velocity + cVector3 dvelocity; }; } #endif //! CAUDIO_H_INCLUDED diff --git a/Source/cAudio.cpp b/Source/cAudio.cpp index d61d1e2..561fc4c 100644 --- a/Source/cAudio.cpp +++ b/Source/cAudio.cpp @@ -1,8 +1,7 @@ -#include "../Headers/cAudio.h" #include #include #include - +#include "../Headers/cAudio.h" namespace cAudio { @@ -174,10 +173,11 @@ namespace cAudio } //!Plays the given audio file with 3d position - void cAudio::play3d(bool loop, float x, float y, float z,float soundstr) + void cAudio::play3d(cVector3 position, float soundstr, bool loop) { + this->position = position; alSourcei (source, AL_SOURCE_RELATIVE, false); - alSource3f(source, AL_POSITION, x, y, z); + alSource3f(source, AL_POSITION, position.x, position.y, position.z); alSourcef (source, AL_ROLLOFF_FACTOR, soundstr); toloop = loop; play(); @@ -191,21 +191,24 @@ namespace cAudio } //!Used to move the audio sources position after the initial creation - void cAudio::setPosition(float posx,float posy,float posz) + void cAudio::setPosition(cVector3 position) { - alSource3f(source, AL_POSITION, posx, posy, posz); + this->position = position; + alSource3f(source, AL_POSITION, position.x, position.y, position.z); } //!Used to set the velocity of the audio source. - void cAudio::setVelocity(float velx,float vely, float velz) + void cAudio::setVelocity(cVector3 velocity) { - alSource3f(source, AL_VELOCITY, velx, vely, velz); + this->velocity = velocity; + alSource3f(source, AL_VELOCITY, velocity.x, velocity.y, velocity.z); } //!Used to set the direction of the audio source - void cAudio::setDirection(float dirx,float diry,float dirz) + void cAudio::setDirection(cVector3 direction) { - alSource3f(source, AL_DIRECTION, dirx, diry, dirz); + this->direction = direction; + alSource3f(source, AL_DIRECTION, direction.x, direction.y, direction.z); } //!Used to set the sound strength or roll off factor @@ -233,9 +236,10 @@ namespace cAudio } //!Used to set the doppler velocity of the audio source - void cAudio::setDopplerVelocity(float doopx,float doopy,float doopz) + void cAudio::setDopplerVelocity(cVector3 dvelocity) { - alSource3f(source, AL_DOPPLER_VELOCITY, doopx, doopy, doopz); + this->dvelocity = dvelocity; + alSource3f(source, AL_DOPPLER_VELOCITY, dvelocity.x, dvelocity.y, dvelocity.z); } //!Allows us to seek through a stream diff --git a/cAudio.vcproj b/cAudio.vcproj index 79e4ae0..725278f 100644 --- a/cAudio.vcproj +++ b/cAudio.vcproj @@ -214,14 +214,6 @@ RelativePath=".\Headers\cRawDecoder.h" > - - - - @@ -230,38 +222,6 @@ RelativePath=".\Headers\cWavDecoder.h" > - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/IAudio.h b/include/IAudio.h index 6d6f792..89640fe 100644 --- a/include/IAudio.h +++ b/include/IAudio.h @@ -3,6 +3,7 @@ #include "IAudioDecoder.h" +class cVector3; namespace cAudio { class IAudio @@ -16,13 +17,13 @@ namespace cAudio //!plays the audio file 2d no distance. virtual void play2d(bool loop = false) = 0; //!plays the audio file and sets it to 3d - virtual void play3d(bool loop = false, float x = 0.0, float y = 0.0, float z = 0.0, float soundstr = 1.0) = 0; + virtual void play3d(cVector3 position, float soundstr = 1.0 , bool loop = false) = 0; //!allows us to set the position or reset the position - virtual void setPosition(float posx,float posy,float posz) = 0; + virtual void setPosition(cVector3 position) = 0; //!allows you to set the audio objects velocity - virtual void setVelocity(float velx,float vely,float velz) = 0; + virtual void setVelocity(cVector3 velocity) = 0; //!allows us to set the direction the audio should play in - virtual void setDirection(float dirx,float diry,float dirz) = 0; + virtual void setDirection(cVector3 direction) = 0; //! Sets the audios pitch level virtual void setPitch(float pitch) = 0; //!allows us to set and reset the sound strength @@ -32,7 +33,7 @@ namespace cAudio //!Set the doppler strength virtual void setDopplerStrength(float doop) = 0; //!Set the doppler velocity - virtual void setDopplerVelocity(float doopx,float doopy,float doopz) = 0; + virtual void setDopplerVelocity(cVector3 dvelocity) = 0; //!Seek through the audio stream virtual void seek(float secs) = 0; diff --git a/include/IAudioManager.h b/include/IAudioManager.h index eb42a68..31b3e5f 100644 --- a/include/IAudioManager.h +++ b/include/IAudioManager.h @@ -1,4 +1,3 @@ - #ifndef IAUDIOMANAGER_H #define IAUDIOMANAGER_H #include