Added all needed get functions.

This commit is contained in:
Raynaldo Rivera 2009-08-26 02:19:58 +00:00
parent bcf890f125
commit 4db524e400
7 changed files with 112 additions and 41 deletions

View File

@ -23,21 +23,40 @@ namespace cAudio
void play3d(cVector3 position, float soundstr = 1.0 , bool loop = false);
//!allows us to set the position or reset the position
void setPosition(cVector3 position);
void setPosition(const cVector3 position);
//!allows you to set the audio objects velocity
void setVelocity(cVector3 velocity);
void setVelocity(const cVector3 velocity);
//!allows us to set the direction the audio should play in
void setDirection(cVector3 direction);
void setDirection(const cVector3 direction);
//! Sets the audios pitch level
void setPitch(float pitch);
void setPitch(const float pitch);
//!allows us to set and reset the sound strenght
void setStrength(float soundstrength);
void setStrength(const float soundstrength);
//!Set the volume
void setVolume(float volume);
void setVolume(const float volume);
//!Set the doppler strength
void setDopplerStrength(float doop);
void setDopplerStrength(const float dstrength);
//!Set doppler velocity
void setDopplerVelocity(cVector3 dvelocity);
void setDopplerVelocity(const cVector3 dvelocity);
//!Returns the audio objects position
cVector3 getPosition();
//!Returns the audio objects velocity
cVector3 getVelocity();
//!Returns the audio objects direction
cVector3 getDirection();
//!Returns the audio objects doppler strength
float getDopplerStrength();
//!Returns the audio objects strength
float getStrength();
//!Returns the volume of the sound object
float getVolume();
//!Returns the pitch volume
float getPitch();
//!Returns if the sound object is looping
bool isLooping();
//!Seek the audio stream
void seek(float secs);
@ -98,6 +117,15 @@ namespace cAudio
cVector3 direction;
//! Stores the doppler velocity
cVector3 dvelocity;
//! Stores the volume
float volume;
//! Stores the pitch
float pitch;
//! Stores doppler strength
float dstrength;
//! Stores the objects sound strength
float strength;
};
}
#endif //! CAUDIO_H_INCLUDED

View File

@ -8,8 +8,8 @@ namespace cAudio
class cListener : public IListener
{
public:
cListener() : Direction(0.f, 0.f, -1.f),
UpVector(0.f, 1.f, 0.f),
cListener() : Direction(cVector3(0.f, 0.f, -1.f)),
UpVector(cVector3(0.f, 1.f, 0.f)),
MasterGain(1.f) {}
virtual ~cListener() {}
@ -17,23 +17,17 @@ namespace cAudio
//!Note that this will automatically set velocity to 0
//!Use move() if you'd like to have cAudio automatically handle velocity for you
//!or remember to set it yourself after setPosition
virtual void setPosition(const float x, const float y, const float z) { setPosition(cVector3(x,y,z)); }
virtual void setPosition(const cVector3 pos);
//!Sets the direction the listener is facing
virtual void setDirection(const float x, const float y, const float z) { setDirection(cVector3(x,y,z)); }
virtual void setDirection(const cVector3 dir);
//!Sets the up vector to use for the listener
virtual void setUpVector(const float x, const float y, const float z) { setUpVector(cVector3(x,y,z)); }
virtual void setUpVector(const cVector3 up);
//!Sets the current velocity of the listener for doppler effects
virtual void setVelocity(const float x, const float y, const float z) { setVelocity(cVector3(x,y,z)); }
virtual void setVelocity(const cVector3 vel);
//!Sets the global volume modifier (will effect all sources)
virtual void setMasterVolume(const float volume);
//!Convenience function to automatically set the velocity for you on a move
//!Velocity will be set to new position - last position
virtual void move(const float x, const float y, const float z) { move(cVector3(x,y,z)); }
virtual void move(const cVector3 pos);
//!Returns the current position of the listener

View File

@ -176,6 +176,7 @@ namespace cAudio
void cAudio::play3d(cVector3 position, float soundstr, bool loop)
{
this->position = position;
this->strength = soundstr;
alSourcei (source, AL_SOURCE_RELATIVE, false);
alSource3f(source, AL_POSITION, position.x, position.y, position.z);
alSourcef (source, AL_ROLLOFF_FACTOR, soundstr);
@ -191,57 +192,93 @@ namespace cAudio
}
//!Used to move the audio sources position after the initial creation
void cAudio::setPosition(cVector3 position)
void cAudio::setPosition(const cVector3 position)
{
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(cVector3 velocity)
void cAudio::setVelocity(const cVector3 velocity)
{
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(cVector3 direction)
void cAudio::setDirection(const cVector3 direction)
{
this->direction = direction;
alSource3f(source, AL_DIRECTION, direction.x, direction.y, direction.z);
}
//!Used to set the sound strength or roll off factor
void cAudio::setStrength(float soundstrength)
void cAudio::setStrength(const float soundstrength)
{
alSourcef(source, AL_ROLLOFF_FACTOR, soundstrength);
}
//!Used to set the pitch of the audio file
void cAudio::setPitch(float pitch)
void cAudio::setPitch(const float pitch)
{
this->pitch = pitch;
alSourcef (source, AL_PITCH, pitch);
}
//!Used to set the volume of the audio source
void cAudio::setVolume(float volume)
void cAudio::setVolume(const float volume)
{
this->volume = volume;
alSourcef(source, AL_GAIN, volume);
}
//!Used to set the doppler strength of the audio sources doppler effect
void cAudio::setDopplerStrength(float doop)
void cAudio::setDopplerStrength(const float dstrength)
{
alSourcef(source, AL_DOPPLER_FACTOR, doop);
this->dstrength = dstrength;
alSourcef(source, AL_DOPPLER_FACTOR, dstrength);
}
//!Used to set the doppler velocity of the audio source
void cAudio::setDopplerVelocity(cVector3 dvelocity)
void cAudio::setDopplerVelocity(const cVector3 dvelocity)
{
this->dvelocity = dvelocity;
alSource3f(source, AL_DOPPLER_VELOCITY, dvelocity.x, dvelocity.y, dvelocity.z);
}
cVector3 cAudio::getPosition()
{
return this->position;
}
cVector3 cAudio::getVelocity(){
return this->velocity;
}
cVector3 cAudio::getDirection(){
return this->direction;
}
float cAudio::getDopplerStrength(){
return this->dstrength;
}
float cAudio::getStrength(){
return this->strength;
}
float cAudio::getVolume(){
return this->volume;
}
float cAudio::getPitch(){
return this->pitch;
}
bool cAudio::isLooping(){
return this->toloop;
}
//!Allows us to seek through a stream
void cAudio::seek(float secs)
{

View File

@ -253,13 +253,13 @@ namespace cAudio
//!Sets the listeners position.
void cAudioManager::setListenerPos(float x,float y,float z)
{
initlistener.setPosition(x,y,z);
initlistener.setPosition(cVector3(x,y,z));
}
//!Sets the listener orientation
void cAudioManager::setListenerOrientation(float ux,float uy,float uz)
{
initlistener.setUpVector(ux,uy,uz);
initlistener.setUpVector(cVector3(ux,uy,uz));
}
}

View File

@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cAudio", "cAudio.vcproj", "{ACD6C202-85D4-44F5-83BF-6577A074F655}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tutorial1_2DSound", "Examples\Tutorial1_2DSound\Tutorial1_2DSound.vcproj", "{D7A934F9-003B-47F7-AAD6-F360A4D41B9B}"

View File

@ -19,24 +19,41 @@ namespace cAudio
//!plays the audio file and sets it to 3d
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(cVector3 position) = 0;
virtual void setPosition(const cVector3 position) = 0;
//!allows you to set the audio objects velocity
virtual void setVelocity(cVector3 velocity) = 0;
virtual void setVelocity(const cVector3 velocity) = 0;
//!allows us to set the direction the audio should play in
virtual void setDirection(cVector3 direction) = 0;
virtual void setDirection(const cVector3 direction) = 0;
//! Sets the audios pitch level
virtual void setPitch(float pitch) = 0;
virtual void setPitch(const float pitch) = 0;
//!allows us to set and reset the sound strength
virtual void setStrength(float soundstrength) = 0;
virtual void setStrength(const float soundstrength) = 0;
//! Set the volume
virtual void setVolume(float volume) = 0;
virtual void setVolume(const float volume) = 0;
//!Set the doppler strength
virtual void setDopplerStrength(float doop) = 0;
virtual void setDopplerStrength(const float dstrength) = 0;
//!Set the doppler velocity
virtual void setDopplerVelocity(cVector3 dvelocity) = 0;
virtual void setDopplerVelocity(const cVector3 dvelocity) = 0;
//!Seek through the audio stream
virtual void seek(float secs) = 0;
//!Returns the audio objects position
virtual cVector3 getPosition() = 0;
//!Returns the audio objects velocity
virtual cVector3 getVelocity() = 0;
//!Returns the audio objects direction
virtual cVector3 getDirection() = 0;
//!Returns the audio objects doppler strength
virtual float getDopplerStrength() = 0;
//!Returns the audio objects strength
virtual float getStrength() = 0;
//!Returns the volume of the sound object
virtual float getVolume() = 0;
//!Returns the pitch volume
virtual float getPitch() = 0;
//!Returns if the sound object is looping
virtual bool isLooping() = 0;
//!release the file handle
virtual void release() = 0;
//!pauses the audio file

View File

@ -16,23 +16,18 @@ namespace cAudio
//!Note that this will automatically set velocity to 0
//!Use move() if you'd like to have cAudio automatically handle velocity for you
//!or remember to set it yourself after setPosition
virtual void setPosition(const float x, const float y, const float z) = 0;
virtual void setPosition(const cVector3 pos) = 0;
//!Sets the direction the listener is facing
virtual void setDirection(const float x, const float y, const float z) = 0;
virtual void setDirection(const cVector3 dir) = 0;
//!Sets the up vector to use for the listener
virtual void setUpVector(const float x, const float y, const float z) = 0;
virtual void setUpVector(const cVector3 up) = 0;
//!Sets the current velocity of the listener for doppler effects
virtual void setVelocity(const float x, const float y, const float z) = 0;
virtual void setVelocity(const cVector3 vel) = 0;
//!Sets the global volume modifier (will effect all sources)
virtual void setMasterVolume(const float volume) = 0;
//!Convenience function to automatically set the velocity for you on a move
//!Velocity will be set to new position - last position
virtual void move(const float x, const float y, const float z) = 0;
virtual void move(const cVector3 pos) = 0;
//!Returns the current position of the listener