Updated the examples to use a better set of characters to denote the default device
Removed an unnecessary include in cAudioManager.h Added a define to set the number of buffers used by an audio source Added the last of the previously unsupported OpenAL source parameters (Cones, attenuation tweaking, max/min volume, and rolloff factor) Cleaned up the implementation of cAudio source. It no longer keeps a redundant copy of the state information and functions are now in order that they are defined. Some functions have been renamed to be clearer. Other changes throughout the code to support the changes to the cAudio source.
This commit is contained in:
parent
cd1a2a61d9
commit
e1bf4ecc9a
|
@ -26,7 +26,7 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
std::string deviceName = manager->getAvailableDeviceName(i);
|
||||
if(deviceName.compare(defaultDeviceName) == 0)
|
||||
cout << i << "): " << deviceName << " (DEFAULT) \n";
|
||||
cout << i << "): " << deviceName << " [DEFAULT] \n";
|
||||
else
|
||||
cout << i << "): " << deviceName << " \n";
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ int main(int argc, char* argv[])
|
|||
mysound->play2d(false);
|
||||
|
||||
//Wait for the sound to finish playing
|
||||
while(mysound->playing())
|
||||
while(mysound->isPlaying())
|
||||
cAudio::cAudioSleep(10);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
std::string deviceName = manager->getAvailableDeviceName(i);
|
||||
if(deviceName.compare(defaultDeviceName) == 0)
|
||||
cout << i << "): " << deviceName << " (DEFAULT) \n";
|
||||
cout << i << "): " << deviceName << " [DEFAULT] \n";
|
||||
else
|
||||
cout << i << "): " << deviceName << " \n";
|
||||
}
|
||||
|
@ -61,22 +61,24 @@ int main(int argc, char* argv[])
|
|||
if(mysound && listener)
|
||||
{
|
||||
listener->setPosition(cAudio::cVector3(0,0,0));
|
||||
mysound->play3d(cAudio::cVector3(0,0,0),1.0f,true);
|
||||
mysound->setVolume(1.0);
|
||||
mysound->play3d(cAudio::cVector3(0,0,0),2.0f,true);
|
||||
mysound->setVolume(1.0f);
|
||||
mysound->setMinDistance(1.0f);
|
||||
mysound->setMaxDistance(100.0f);
|
||||
|
||||
//Play for 10 seconds
|
||||
const int ticksToPlay = 10000;
|
||||
int currentTick = 0;
|
||||
int currentSecTick = 0;
|
||||
|
||||
while(mysound->playing() && currentTick < ticksToPlay)
|
||||
while(mysound->isPlaying() && currentTick < ticksToPlay)
|
||||
{
|
||||
//Figure out the location of our rotated sound
|
||||
rot+=0.1f * 0.017453293f; //0.1 degrees a frame
|
||||
|
||||
//Sound "starts" at x=2.5, y=0, z=0
|
||||
float x = 2.5f * cosf(rot) - 0.0f * sinf(rot);
|
||||
float z = 0.0f * cosf(rot) + 2.5f * sinf(rot);
|
||||
//Sound "starts" at x=5, y=0, z=0
|
||||
float x = 5.0f * cosf(rot) - 0.0f * sinf(rot);
|
||||
float z = 0.0f * cosf(rot) + 5.0f * sinf(rot);
|
||||
mysound->setPosition(cAudio::cVector3(x,0.0,z));
|
||||
|
||||
++currentTick;
|
||||
|
|
|
@ -37,7 +37,7 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
std::string deviceName = manager->getAvailableDeviceName(i);
|
||||
if(deviceName.compare(defaultDeviceName) == 0)
|
||||
cout << i << "): " << deviceName << " (DEFAULT) \n";
|
||||
cout << i << "): " << deviceName << " [DEFAULT] \n";
|
||||
else
|
||||
cout << i << "): " << deviceName << " \n";
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
std::string deviceName = capture->getAvailableDeviceName(i);
|
||||
if(deviceName.compare(defaultDeviceName) == 0)
|
||||
cout << i << "): " << deviceName << " (DEFAULT) \n";
|
||||
cout << i << "): " << deviceName << " [DEFAULT] \n";
|
||||
else
|
||||
cout << i << "): " << deviceName << " \n";
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ int main(int argc, char* argv[])
|
|||
//Set the IAudio Sound to play2d and loop
|
||||
mysound->play2d(false);
|
||||
|
||||
while(mysound->playing())
|
||||
while(mysound->isPlaying())
|
||||
{
|
||||
//Sleep for 10 ms to free some CPU
|
||||
cAudio::cAudioSleep(10);
|
||||
|
|
242
Headers/cAudio.h
242
Headers/cAudio.h
|
@ -6,130 +6,170 @@
|
|||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
|
||||
#define BUFFER_SIZE ( 1024 * 64 )
|
||||
#include "../include/IAudio.h"
|
||||
#include "../Include/cVector3.h"
|
||||
#include "../Headers/cMutex.h"
|
||||
#include "../include/ILogger.h"
|
||||
|
||||
//! Size of each internal buffer for sound (total amount buffered is BUFFER_SIZE * NUM_BUFFERS)
|
||||
#define BUFFER_SIZE ( 1024 * 64 )
|
||||
//! Number of internal buffers to cycle through (Note: using only 1 leads to choppy sound or premature ending of sources)
|
||||
#define NUM_BUFFERS 3
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
class cAudio : public IAudio
|
||||
{
|
||||
public:
|
||||
//! play with defualts / the last set values
|
||||
bool play();
|
||||
//!plays the audio file 2d no distance.
|
||||
void play2d(bool loop = false);
|
||||
//!plays the audio file and sets it to 3d
|
||||
void play3d(cVector3 position, float soundstr = 1.0 , bool loop = false);
|
||||
|
||||
//!allows us to set the position or reset the position
|
||||
void setPosition(const cVector3 position);
|
||||
//!allows you to set the audio objects velocity
|
||||
void setVelocity(const cVector3 velocity);
|
||||
//!allows us to set the direction the audio should play in
|
||||
void setDirection(const cVector3 direction);
|
||||
//! Sets the audios pitch level
|
||||
void setPitch(const float pitch);
|
||||
//!allows us to set and reset the sound strenght
|
||||
void setStrength(const float soundstrength);
|
||||
//!Set the volume
|
||||
void setVolume(const float volume);
|
||||
//!Set the doppler strength
|
||||
void setDopplerStrength(const float dstrength);
|
||||
//!Set doppler velocity
|
||||
void setDopplerVelocity(const cVector3 dvelocity);
|
||||
|
||||
//!Returns the audio objects position
|
||||
const cVector3& getPosition()const;
|
||||
//!Returns the audio objects velocity
|
||||
const cVector3& getVelocity()const;
|
||||
//!Returns the audio objects direction
|
||||
const cVector3& getDirection()const;
|
||||
//!Returns the audio objects doppler strength
|
||||
const float& getDopplerStrength()const;
|
||||
//!Returns the audio objects strength
|
||||
const float& getStrength()const;
|
||||
//!Returns the volume of the sound object
|
||||
const float& getVolume()const;
|
||||
//!Returns the pitch volume
|
||||
const float& getPitch()const;
|
||||
//!Returns if the sound object is looping
|
||||
const bool& isLooping()const;
|
||||
|
||||
|
||||
|
||||
//!Seek the audio stream
|
||||
void seek(float secs);
|
||||
//!release the file handle
|
||||
void release();
|
||||
//!pauses the audio file
|
||||
void pause();
|
||||
//!controls altering of the looping to make it loop or not to.
|
||||
void loop(bool loop);
|
||||
//!stops the audio file from playing
|
||||
void stop();
|
||||
|
||||
//!returns if playing
|
||||
bool playback();
|
||||
//!check if source is playing
|
||||
bool playing();
|
||||
//!update the stream
|
||||
bool update();
|
||||
//!checks to make sure everything is ready to go
|
||||
bool isvalid();
|
||||
//!returns the current OpenalSource
|
||||
const ALuint& getSource()const;
|
||||
|
||||
cAudio(IAudioDecoder* decoder);
|
||||
~cAudio();
|
||||
|
||||
//! Plays the source with the default or last set values
|
||||
virtual bool play();
|
||||
//! Plays the source in 2D mode
|
||||
virtual bool play2d(const bool& toLoop = false);
|
||||
//! Plays the source in 3D mode
|
||||
virtual bool play3d(const cVector3& position, const float& soundstr = 1.0 , const bool& toLoop = false);
|
||||
|
||||
//! Pauses playback of the sound source
|
||||
virtual void pause();
|
||||
//! Stops playback of the sound source
|
||||
virtual void stop();
|
||||
//! Controls whether the source should loop or not
|
||||
virtual void loop(const bool& toLoop);
|
||||
//! Seeks through the audio stream to a specific spot
|
||||
/** Note: May not be supported by all codecs
|
||||
\param seconds: Number of seconds from the start of the audio stream to seek to
|
||||
\return True on success, False if the codec does not support seeking. */
|
||||
virtual bool seek(const float& seconds);
|
||||
|
||||
//! Normally called every frame by the audio manager to update the internal buffers
|
||||
//! Note: For internal use only.
|
||||
virtual bool update();
|
||||
//! Releases all resources used by the audio source, normally used to clean up before deletion
|
||||
//! Note: For internal use only.
|
||||
virtual void release();
|
||||
|
||||
//! Returns if the source is ready to be used
|
||||
virtual const bool isValid() const;
|
||||
//! Returns if the source is playing
|
||||
virtual const bool isPlaying() const;
|
||||
//! Returns if the source is paused
|
||||
virtual const bool isPaused() const;
|
||||
//! Returns if the source is stopped
|
||||
virtual const bool isStopped() const;
|
||||
//! Returns if the source is looping
|
||||
virtual const bool isLooping() const;
|
||||
|
||||
//! Sets the position of the source in 3D space
|
||||
virtual void setPosition(const cVector3& position);
|
||||
//! Sets the current velocity of the source for doppler effects
|
||||
virtual void setVelocity(const cVector3& velocity);
|
||||
//! Sets the direction the source is facing
|
||||
virtual void setDirection(const cVector3& direction);
|
||||
|
||||
//! 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)
|
||||
virtual void setRolloffFactor(const float& rolloff);
|
||||
//! Sets how well the source carries over distance
|
||||
//! Same as setRolloffFactor(1.0f/soundstrength)
|
||||
//! Range: 0.0f to +inf (Default: 1.0f)
|
||||
virtual void setStrength(const float& soundstrength);
|
||||
//! Sets the distance from the source where attenuation will begin
|
||||
//! Range: 0.0f to +inf
|
||||
virtual void setMinDistance(const float& minDistance);
|
||||
//! Sets the distance from the source where attenuation will stop
|
||||
//! Range: 0.0f to +inf
|
||||
virtual void setMaxDistance(const float& maxDistance);
|
||||
|
||||
//! Sets the pitch of the source
|
||||
virtual void setPitch(const float& pitch);
|
||||
//! Sets the source volume before attenuation and other effects
|
||||
//! Range: 0.0f to +inf (Default: 1.0f)
|
||||
virtual void setVolume(const float& volume);
|
||||
//! Sets the minimum volume that the source can be attenuated to
|
||||
//! Range: 0.0f to +inf (Default: 0.0f)
|
||||
virtual void setMinVolume(const float& minVolume);
|
||||
//! Sets the maximum volume that the source can achieve
|
||||
//! Range: 0.0f to +inf (Default: 1.0f)
|
||||
virtual void setMaxVolume(const float& maxVolume);
|
||||
|
||||
//! Sets the angle of the inner sound cone of the source
|
||||
//! 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)
|
||||
virtual void setInnerConeAngle(const float& innerAngle);
|
||||
//! Sets the angle of the outer sound cone of the source
|
||||
//! 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)
|
||||
virtual void setOuterConeAngle(const float& outerAngle);
|
||||
//! Sets how much the volume of the source is scaled in the outer cone
|
||||
//! Range: 0.0f to +inf (Default: 0.0f)
|
||||
virtual void setOuterConeVolume(const float& outerVolume);
|
||||
|
||||
//! Sets the doppler strength, which enhances or diminishes the doppler effect
|
||||
//! Range: 0.0f to +inf (Default: 1.0f)
|
||||
virtual void setDopplerStrength(const float& dstrength);
|
||||
//! Overrides the doppler velocity vector
|
||||
virtual void setDopplerVelocity(const cVector3& dvelocity);
|
||||
|
||||
//!Returns the audio objects position
|
||||
virtual const cVector3 getPosition() const;
|
||||
//!Returns the audio objects velocity
|
||||
virtual const cVector3 getVelocity() const;
|
||||
//!Returns the audio objects direction
|
||||
virtual const cVector3 getDirection() const;
|
||||
|
||||
//! Returns the factor used in attenuating the source over distance
|
||||
virtual const float getRolloffFactor() const;
|
||||
//! Returns the strength of the source
|
||||
virtual const float getStrength() const;
|
||||
//! Returns the distance from the source where attenuation will begin
|
||||
virtual const float getMinDistance() const;
|
||||
//! Returns the distance from the source where attenuation will stop
|
||||
virtual const float getMaxDistance() const;
|
||||
|
||||
//!Returns the pitch of the source
|
||||
virtual const float getPitch() const;
|
||||
//!Returns the source volume before attenuation and other effects
|
||||
virtual const float getVolume() const;
|
||||
//! Returns the minimum volume that the source can be attenuated to
|
||||
virtual const float getMinVolume() const;
|
||||
//! Returns the maximum volume that the source can achieve
|
||||
virtual const float getMaxVolume() const;
|
||||
|
||||
//! Returns the angle of the inner sound cone of the source
|
||||
virtual const float getInnerConeAngle() const;
|
||||
//! Returns the angle of the outer sound cone of the source
|
||||
virtual const float getOuterConeAngle() const;
|
||||
//! Returns how much the volume of the source is scaled in the outer cone
|
||||
virtual const float getOuterConeVolume() const;
|
||||
|
||||
//!Returns the doppler strength, which enhances or diminishes the doppler effect
|
||||
virtual const float getDopplerStrength() const;
|
||||
//!Returns the override for the doppler velocity vector
|
||||
virtual const cVector3 getDopplerVelocity() const;
|
||||
|
||||
protected:
|
||||
private:
|
||||
//Mutex for thread syncronization
|
||||
cAudioMutex Mutex;
|
||||
//!empties the queue
|
||||
//Empties the current working buffer queue
|
||||
void empty();
|
||||
//!checks openal error state
|
||||
//Checks for OpenAL errors and reports them
|
||||
void checkError();
|
||||
//!reloads a buffer
|
||||
//Steams audio data from the decoder into a buffer
|
||||
bool stream(ALuint buffer);
|
||||
|
||||
//! front and back buffers
|
||||
ALuint buffers[3];
|
||||
//! audio source
|
||||
ALuint source;
|
||||
//! decoder pointer
|
||||
//Internal audio buffers
|
||||
ALuint Buffers[NUM_BUFFERS];
|
||||
//OpenAL source
|
||||
ALuint Source;
|
||||
//cAudio decoder being used to stream data
|
||||
IAudioDecoder* Decoder;
|
||||
|
||||
//! if the file to be played is going to be streamed
|
||||
bool streaming;
|
||||
//!if the file is to loop
|
||||
bool toloop;
|
||||
//!if the file should play
|
||||
bool playaudio;
|
||||
//!if to pause audio
|
||||
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;
|
||||
//! Stores the volume
|
||||
float volume;
|
||||
//! Stores the pitch
|
||||
float pitch;
|
||||
//! Stores doppler strength
|
||||
float dstrength;
|
||||
//! Stores the objects sound strength
|
||||
float strength;
|
||||
|
||||
//Stores whether the source is to loop the audio stream
|
||||
bool Loop;
|
||||
};
|
||||
}
|
||||
#endif //! CAUDIO_H_INCLUDED
|
||||
|
|
|
@ -9,15 +9,12 @@ namespace cAudio
|
|||
cAudio::cAudio(IAudioDecoder* decoder) : Decoder(decoder)
|
||||
{
|
||||
Mutex.lock();
|
||||
streaming = false;
|
||||
playaudio = false;
|
||||
pauseaudio = false;
|
||||
toloop = false;
|
||||
Loop = false;
|
||||
|
||||
//Generates 3 buffers for the ogg file
|
||||
alGenBuffers(3, buffers);
|
||||
alGenBuffers(NUM_BUFFERS, Buffers);
|
||||
//Creates one source to be stored.
|
||||
alGenSources(1, &source);
|
||||
alGenSources(1, &Source);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
@ -29,80 +26,117 @@ namespace cAudio
|
|||
Mutex.unlock();
|
||||
}
|
||||
|
||||
//!Stops all playing sound sources and deletes the sources and buffers
|
||||
void cAudio::release()
|
||||
{
|
||||
bool cAudio::play()
|
||||
{
|
||||
Mutex.lock();
|
||||
//Stops the audio source
|
||||
alSourceStop(source);
|
||||
empty();
|
||||
//Deletes the source
|
||||
alDeleteSources(1, &source);
|
||||
//deletes the last filled buffer
|
||||
alDeleteBuffers(3, buffers);
|
||||
if (!isPaused())
|
||||
{
|
||||
int queueSize = 0;
|
||||
for(int u = 0; u < NUM_BUFFERS; u++)
|
||||
{
|
||||
int val = stream(Buffers[u]);
|
||||
|
||||
if(val < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(val > 0)
|
||||
++queueSize;
|
||||
}
|
||||
//Stores the sources 3 buffers to be used in the queue
|
||||
alSourceQueueBuffers(Source, queueSize, Buffers);
|
||||
checkError();
|
||||
}
|
||||
alSourcePlay(Source);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
getLogger()->logDebug("Audio Source", "Audio source released.");
|
||||
getLogger()->logDebug("Audio Source", "Source playing.");
|
||||
return true;
|
||||
}
|
||||
|
||||
//!Plays back sound source
|
||||
bool cAudio::playback()
|
||||
{
|
||||
bool cAudio::play2d(const bool& toLoop)
|
||||
{
|
||||
Mutex.lock();
|
||||
bool play = playing();
|
||||
alSourcei(Source, AL_SOURCE_RELATIVE, true);
|
||||
loop(toLoop);
|
||||
bool state = play();
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
return play;
|
||||
return state;
|
||||
}
|
||||
|
||||
bool cAudio::paused()
|
||||
{
|
||||
bool cAudio::play3d(const cVector3& position, const float& soundstr, const bool& toLoop)
|
||||
{
|
||||
Mutex.lock();
|
||||
ALenum state = 0;
|
||||
|
||||
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
||||
|
||||
alSourcei(Source, AL_SOURCE_RELATIVE, false);
|
||||
setPosition(position);
|
||||
setStrength(soundstr);
|
||||
loop(toLoop);
|
||||
bool state = play();
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
return (state == AL_PAUSED);
|
||||
return state;
|
||||
}
|
||||
|
||||
//!checks to see if audio source is playing if it is returns true
|
||||
bool cAudio::playing()
|
||||
{
|
||||
void cAudio::pause()
|
||||
{
|
||||
Mutex.lock();
|
||||
ALenum state = 0;
|
||||
|
||||
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
||||
|
||||
alSourcePause(Source);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
return (state == AL_PLAYING);
|
||||
getLogger()->logDebug("Audio Source", "Source paused.");
|
||||
}
|
||||
|
||||
void cAudio::stop()
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourceStop(Source);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
getLogger()->logDebug("Audio Source", "Source stopped.");
|
||||
}
|
||||
|
||||
//!updates the sound source by refilling the buffers with ogg data.
|
||||
bool cAudio::update()
|
||||
{
|
||||
void cAudio::loop(const bool& loop)
|
||||
{
|
||||
Mutex.lock();
|
||||
if(!isvalid() || !playing())
|
||||
Loop = loop;
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
bool cAudio::seek(const float& seconds)
|
||||
{
|
||||
bool state = false;
|
||||
Mutex.lock();
|
||||
if(Decoder->isSeekingSupported())
|
||||
{
|
||||
state = Decoder->seek(seconds, false);
|
||||
}
|
||||
Mutex.unlock();
|
||||
return state;
|
||||
}
|
||||
|
||||
bool cAudio::update()
|
||||
{
|
||||
if(!isValid() || !isPlaying())
|
||||
{
|
||||
Mutex.unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
int processed = 0;
|
||||
bool active = true;
|
||||
//gets the sound source processed buffers/
|
||||
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
|
||||
|
||||
Mutex.lock();
|
||||
//gets the sound source processed buffers
|
||||
alGetSourcei(Source, AL_BUFFERS_PROCESSED, &processed);
|
||||
//while there is more data refill buffers with audio data.
|
||||
while (processed--)
|
||||
{
|
||||
ALuint buffer;
|
||||
|
||||
alSourceUnqueueBuffers(source, 1, &buffer);
|
||||
|
||||
alSourceUnqueueBuffers(Source, 1, &buffer);
|
||||
active = stream(buffer);
|
||||
|
||||
//if more in stream continue playing.
|
||||
if(active)
|
||||
alSourceQueueBuffers(source, 1, &buffer);
|
||||
alSourceQueueBuffers(Source, 1, &buffer);
|
||||
|
||||
checkError();
|
||||
}
|
||||
|
@ -110,7 +144,330 @@ namespace cAudio
|
|||
return active;
|
||||
}
|
||||
|
||||
//!The streaming function
|
||||
void cAudio::release()
|
||||
{
|
||||
Mutex.lock();
|
||||
//Stops the audio Source
|
||||
alSourceStop(Source);
|
||||
empty();
|
||||
//Deletes the source
|
||||
alDeleteSources(1, &Source);
|
||||
//deletes the last filled buffer
|
||||
alDeleteBuffers(NUM_BUFFERS, Buffers);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
getLogger()->logDebug("Audio Source", "Audio source released.");
|
||||
}
|
||||
|
||||
const bool cAudio::isValid() const
|
||||
{
|
||||
bool state = (Decoder != 0);
|
||||
return state;
|
||||
}
|
||||
|
||||
const bool cAudio::isPlaying() const
|
||||
{
|
||||
ALenum state = 0;
|
||||
alGetSourcei(Source, AL_SOURCE_STATE, &state);
|
||||
return (state == AL_PLAYING);
|
||||
}
|
||||
|
||||
const bool cAudio::isPaused() const
|
||||
{
|
||||
ALenum state = 0;
|
||||
alGetSourcei(Source, AL_SOURCE_STATE, &state);
|
||||
return (state == AL_PAUSED);
|
||||
}
|
||||
|
||||
const bool cAudio::isStopped() const
|
||||
{
|
||||
ALenum state = 0;
|
||||
alGetSourcei(Source, AL_SOURCE_STATE, &state);
|
||||
return (state == AL_STOPPED);
|
||||
}
|
||||
|
||||
const bool cAudio::isLooping() const
|
||||
{
|
||||
return Loop;
|
||||
}
|
||||
|
||||
void cAudio::setPosition(const cVector3& position)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSource3f(Source, AL_POSITION, position.x, position.y, position.z);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setVelocity(const cVector3& velocity)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSource3f(Source, AL_VELOCITY, velocity.x, velocity.y, velocity.z);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setDirection(const cVector3& direction)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSource3f(Source, AL_DIRECTION, direction.x, direction.y, direction.z);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setRolloffFactor(const float& rolloff)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcef(Source, AL_ROLLOFF_FACTOR, rolloff);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setStrength(const float& soundstrength)
|
||||
{
|
||||
float inverseStrength = 0.0f;
|
||||
if(soundstrength > 0.0f)
|
||||
inverseStrength = 1.0f / soundstrength;
|
||||
|
||||
Mutex.lock();
|
||||
alSourcef(Source, AL_ROLLOFF_FACTOR, inverseStrength);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setMinDistance(const float& minDistance)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcef(Source, AL_REFERENCE_DISTANCE, minDistance);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setMaxDistance(const float& maxDistance)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcef(Source, AL_MAX_DISTANCE, maxDistance);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setPitch(const float& pitch)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcef (Source, AL_PITCH, pitch);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setVolume(const float& volume)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcef(Source, AL_GAIN, volume);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setMinVolume(const float& minVolume)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcef(Source, AL_MIN_GAIN, minVolume);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setMaxVolume(const float& maxVolume)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcef(Source, AL_MAX_GAIN, maxVolume);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setInnerConeAngle(const float& innerAngle)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcef(Source, AL_CONE_INNER_ANGLE, innerAngle);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setOuterConeAngle(const float& outerAngle)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcef(Source, AL_CONE_OUTER_ANGLE, outerAngle);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setOuterConeVolume(const float& outerVolume)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcef(Source, AL_CONE_OUTER_GAIN, outerVolume);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setDopplerStrength(const float& dstrength)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcef(Source, AL_DOPPLER_FACTOR, dstrength);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
void cAudio::setDopplerVelocity(const cVector3& dvelocity)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSource3f(Source, AL_DOPPLER_VELOCITY, dvelocity.x, dvelocity.y, dvelocity.z);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
const cVector3 cAudio::getPosition() const
|
||||
{
|
||||
cVector3 position;
|
||||
alGetSourcefv(Source, AL_POSITION, &position.x);
|
||||
return position;
|
||||
}
|
||||
|
||||
const cVector3 cAudio::getVelocity() const
|
||||
{
|
||||
cVector3 velocity;
|
||||
alGetSourcefv(Source, AL_VELOCITY, &velocity.x);
|
||||
return velocity;
|
||||
}
|
||||
|
||||
const cVector3 cAudio::getDirection() const
|
||||
{
|
||||
cVector3 direction;
|
||||
alGetSourcefv(Source, AL_DIRECTION, &direction.x);
|
||||
return direction;
|
||||
}
|
||||
|
||||
const float cAudio::getRolloffFactor() const
|
||||
{
|
||||
float value = 0.0f;
|
||||
alGetSourcef(Source, AL_ROLLOFF_FACTOR, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const float cAudio::getStrength() const
|
||||
{
|
||||
float value = 0.0f;
|
||||
alGetSourcef(Source, AL_ROLLOFF_FACTOR, &value);
|
||||
|
||||
float inverseStrength = 0.0f;
|
||||
if(value > 0.0f)
|
||||
inverseStrength = 1.0f / value;
|
||||
|
||||
return inverseStrength;
|
||||
}
|
||||
|
||||
const float cAudio::getMinDistance() const
|
||||
{
|
||||
float value = 0.0f;
|
||||
alGetSourcef(Source, AL_REFERENCE_DISTANCE, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const float cAudio::getMaxDistance() const
|
||||
{
|
||||
float value = 0.0f;
|
||||
alGetSourcef(Source, AL_MAX_DISTANCE, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const float cAudio::getPitch() const
|
||||
{
|
||||
float value = 0.0f;
|
||||
alGetSourcef(Source, AL_PITCH, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const float cAudio::getVolume() const
|
||||
{
|
||||
float value = 0.0f;
|
||||
alGetSourcef(Source, AL_GAIN, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const float cAudio::getMinVolume() const
|
||||
{
|
||||
float value = 0.0f;
|
||||
alGetSourcef(Source, AL_MIN_GAIN, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const float cAudio::getMaxVolume() const
|
||||
{
|
||||
float value = 0.0f;
|
||||
alGetSourcef(Source, AL_MAX_GAIN, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const float cAudio::getInnerConeAngle() const
|
||||
{
|
||||
float value = 0.0f;
|
||||
alGetSourcef(Source, AL_CONE_INNER_ANGLE, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const float cAudio::getOuterConeAngle() const
|
||||
{
|
||||
float value = 0.0f;
|
||||
alGetSourcef(Source, AL_CONE_OUTER_ANGLE, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const float cAudio::getOuterConeVolume() const
|
||||
{
|
||||
float value = 0.0f;
|
||||
alGetSourcef(Source, AL_CONE_OUTER_GAIN, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const float cAudio::getDopplerStrength() const
|
||||
{
|
||||
float value = 0.0f;
|
||||
alGetSourcef(Source, AL_DOPPLER_FACTOR, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const cVector3 cAudio::getDopplerVelocity() const
|
||||
{
|
||||
cVector3 velocity;
|
||||
alGetSourcefv(Source, AL_DOPPLER_VELOCITY, &velocity.x);
|
||||
return velocity;
|
||||
}
|
||||
|
||||
void cAudio::empty()
|
||||
{
|
||||
int queued = 0;
|
||||
alGetSourcei(Source, AL_BUFFERS_QUEUED, &queued);
|
||||
|
||||
while (queued--)
|
||||
{
|
||||
ALuint buffer;
|
||||
alSourceUnqueueBuffers(Source, 1, &buffer);
|
||||
checkError();
|
||||
}
|
||||
}
|
||||
|
||||
void cAudio::checkError()
|
||||
{
|
||||
int error = alGetError();
|
||||
const char* errorString;
|
||||
|
||||
if (error != AL_NO_ERROR)
|
||||
{
|
||||
errorString = alGetString(error);
|
||||
if(error == AL_OUT_OF_MEMORY)
|
||||
getLogger()->logCritical("Audio Source", "OpenAL Error: %s.", errorString);
|
||||
else
|
||||
getLogger()->logError("Audio Source", "OpenAL Error: %s.", errorString);
|
||||
}
|
||||
}
|
||||
|
||||
bool cAudio::stream(ALuint buffer)
|
||||
{
|
||||
if(Decoder)
|
||||
|
@ -137,10 +494,10 @@ namespace cAudio
|
|||
}
|
||||
if(actualread == 0)
|
||||
{
|
||||
if(toloop)
|
||||
if(isLooping())
|
||||
{
|
||||
//If we are to loop, set to the beginning and reload from the start
|
||||
Decoder->setPosition(0,false);
|
||||
Decoder->setPosition(0, false);
|
||||
getLogger()->logDebug("Audio Source", "Buffer looping.");
|
||||
}
|
||||
else
|
||||
|
@ -160,268 +517,4 @@ namespace cAudio
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//!clears the sound sources buffers and makes them free to be used by other sound sources.
|
||||
void cAudio::empty()
|
||||
{
|
||||
int queued = 0;
|
||||
//grabs allt he sources buffers.
|
||||
alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
|
||||
|
||||
while (queued--)
|
||||
{
|
||||
ALuint buffer;
|
||||
//unqueues sources buffers to be used for others.
|
||||
alSourceUnqueueBuffers(source, 1, &buffer);
|
||||
checkError();
|
||||
}
|
||||
}
|
||||
|
||||
//!Checks the given functions
|
||||
void cAudio::checkError()
|
||||
{
|
||||
int error = alGetError();
|
||||
const char* errorString;
|
||||
|
||||
if (error != AL_NO_ERROR)
|
||||
{
|
||||
errorString = alGetString(error);
|
||||
if(error == AL_OUT_OF_MEMORY)
|
||||
getLogger()->logCritical("Audio Source", "OpenAL Error: %s.", errorString);
|
||||
else
|
||||
getLogger()->logError("Audio Source", "OpenAL Error: %s.", errorString);
|
||||
}
|
||||
}
|
||||
|
||||
//!checks to see if the given ogg file is valid
|
||||
bool cAudio::isvalid()
|
||||
{
|
||||
Mutex.lock();
|
||||
bool state = (Decoder != 0);
|
||||
Mutex.unlock();
|
||||
return state;
|
||||
}
|
||||
|
||||
//!Sets the sound source relativity to follow the listener to give the illusion of stereo 2d sound
|
||||
void cAudio::play2d(bool loop)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcei (source, AL_SOURCE_RELATIVE, true);
|
||||
toloop = loop;
|
||||
play();
|
||||
alSourcePlay(source);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
//!Plays the given audio file with 3d position
|
||||
void cAudio::play3d(cVector3 position, float soundstr, bool loop)
|
||||
{
|
||||
Mutex.lock();
|
||||
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);
|
||||
toloop = loop;
|
||||
play();
|
||||
alSourcePlay(source);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
//!Used to tell the soundsource to loop or not
|
||||
void cAudio::loop(bool loop)
|
||||
{
|
||||
Mutex.lock();
|
||||
toloop = loop;
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
//!Used to move the audio sources position after the initial creation
|
||||
void cAudio::setPosition(const cVector3 position)
|
||||
{
|
||||
Mutex.lock();
|
||||
this->position = position;
|
||||
alSource3f(source, AL_POSITION, position.x, position.y, position.z);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
//!Used to set the velocity of the audio source.
|
||||
void cAudio::setVelocity(const cVector3 velocity)
|
||||
{
|
||||
Mutex.lock();
|
||||
this->velocity = velocity;
|
||||
alSource3f(source, AL_VELOCITY, velocity.x, velocity.y, velocity.z);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
//!Used to set the direction of the audio source
|
||||
void cAudio::setDirection(const cVector3 direction)
|
||||
{
|
||||
Mutex.lock();
|
||||
this->direction = direction;
|
||||
alSource3f(source, AL_DIRECTION, direction.x, direction.y, direction.z);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
//!Used to set the sound strength or roll off factor
|
||||
void cAudio::setStrength(const float soundstrength)
|
||||
{
|
||||
Mutex.lock();
|
||||
alSourcef(source, AL_ROLLOFF_FACTOR, soundstrength);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
//!Used to set the pitch of the audio file
|
||||
void cAudio::setPitch(const float pitch)
|
||||
{
|
||||
Mutex.lock();
|
||||
this->pitch = pitch;
|
||||
alSourcef (source, AL_PITCH, pitch);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
//!Used to set the volume of the audio source
|
||||
void cAudio::setVolume(const float volume)
|
||||
{
|
||||
Mutex.lock();
|
||||
this->volume = volume;
|
||||
alSourcef(source, AL_GAIN, volume);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
//!Used to set the doppler strength of the audio sources doppler effect
|
||||
void cAudio::setDopplerStrength(const float dstrength)
|
||||
{
|
||||
Mutex.lock();
|
||||
this->dstrength = dstrength;
|
||||
alSourcef(source, AL_DOPPLER_FACTOR, dstrength);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
//!Used to set the doppler velocity of the audio source
|
||||
void cAudio::setDopplerVelocity(const cVector3 dvelocity)
|
||||
{
|
||||
Mutex.lock();
|
||||
this->dvelocity = dvelocity;
|
||||
alSource3f(source, AL_DOPPLER_VELOCITY, dvelocity.x, dvelocity.y, dvelocity.z);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
const cVector3& cAudio::getPosition()const
|
||||
{
|
||||
return this->position;
|
||||
}
|
||||
|
||||
const cVector3& cAudio::getVelocity()const
|
||||
{
|
||||
return this->velocity;
|
||||
}
|
||||
|
||||
const cVector3& cAudio::getDirection()const
|
||||
{
|
||||
return this->direction;
|
||||
}
|
||||
|
||||
const float& cAudio::getDopplerStrength()const
|
||||
{
|
||||
return this->dstrength;
|
||||
}
|
||||
|
||||
const float& cAudio::getStrength()const
|
||||
{
|
||||
return this->strength;
|
||||
}
|
||||
|
||||
const float& cAudio::getVolume()const
|
||||
{
|
||||
return this->volume;
|
||||
}
|
||||
|
||||
const float& cAudio::getPitch()const
|
||||
{
|
||||
return this->pitch;
|
||||
}
|
||||
|
||||
const bool& cAudio::isLooping()const
|
||||
{
|
||||
return this->toloop;
|
||||
}
|
||||
|
||||
//!Allows us to seek through a stream
|
||||
void cAudio::seek(float secs)
|
||||
{
|
||||
Mutex.lock();
|
||||
if(Decoder->isSeekingSupported())
|
||||
{
|
||||
Decoder->seek(secs, false);
|
||||
}
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
//!Used to play the audio source
|
||||
bool cAudio::play()
|
||||
{
|
||||
Mutex.lock();
|
||||
playaudio = true;
|
||||
if (!paused())
|
||||
{
|
||||
int queueSize = 0;
|
||||
for(int u = 0; u < 3; u++)
|
||||
{
|
||||
int val = stream(buffers[u]);
|
||||
|
||||
if(val < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(val > 0)
|
||||
++queueSize;
|
||||
}
|
||||
//Stores the sources 3 buffers to be used in the queue
|
||||
alSourceQueueBuffers(source, queueSize, buffers);
|
||||
checkError();
|
||||
}
|
||||
alSourcePlay(source);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
getLogger()->logDebug("Audio Source", "Source playing.");
|
||||
return true;
|
||||
}
|
||||
|
||||
//!Used to stop the audio source
|
||||
void cAudio::stop()
|
||||
{
|
||||
Mutex.lock();
|
||||
playaudio = false;
|
||||
alSourceStop(source);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
getLogger()->logDebug("Audio Source", "Source stopped.");
|
||||
}
|
||||
|
||||
//!Used to pause the audio source
|
||||
void cAudio::pause()
|
||||
{
|
||||
Mutex.lock();
|
||||
playaudio = false;
|
||||
alSourcePause(source);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
getLogger()->logDebug("Audio Source", "Source paused.");
|
||||
}
|
||||
|
||||
const ALuint& cAudio::getSource()const
|
||||
{
|
||||
return this->source;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "../Headers/cLogger.h"
|
||||
|
||||
#include <set>
|
||||
#include <iostream>
|
||||
|
||||
#include <AL/efx.h>
|
||||
#include <AL/efx-creative.h>
|
||||
|
@ -315,17 +314,12 @@ namespace cAudio
|
|||
std::map<std::string,IAudio*>::iterator i = audiomap.begin();
|
||||
for (i = audiomap.begin(); i != audiomap.end() ; i++)
|
||||
{
|
||||
if (i->second->isvalid() == true)
|
||||
if (i->second->isValid() == true)
|
||||
{
|
||||
|
||||
if (i->second->update())
|
||||
{
|
||||
|
||||
}
|
||||
/*if (i->second->playback())
|
||||
{
|
||||
|
||||
}*/
|
||||
}
|
||||
}
|
||||
Mutex.unlock();
|
||||
|
|
173
include/IAudio.h
173
include/IAudio.h
|
@ -12,65 +12,132 @@ namespace cAudio
|
|||
IAudio() {}
|
||||
virtual ~IAudio() {}
|
||||
|
||||
//! play with defualts / the last set values
|
||||
virtual bool play() = 0;
|
||||
//!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(cVector3 position, float soundstr = 1.0 , bool loop = false) = 0;
|
||||
//!allows us to set the position or reset the position
|
||||
virtual void setPosition(const cVector3 position) = 0;
|
||||
//!allows you to set the audio objects velocity
|
||||
virtual void setVelocity(const cVector3 velocity) = 0;
|
||||
//!allows us to set the direction the audio should play in
|
||||
virtual void setDirection(const cVector3 direction) = 0;
|
||||
//! Sets the audios pitch level
|
||||
virtual void setPitch(const float pitch) = 0;
|
||||
//!allows us to set and reset the sound strength
|
||||
virtual void setStrength(const float soundstrength) = 0;
|
||||
//! Set the volume
|
||||
virtual void setVolume(const float volume) = 0;
|
||||
//!Set the doppler strength
|
||||
virtual void setDopplerStrength(const float dstrength) = 0;
|
||||
//!Set the doppler velocity
|
||||
virtual void setDopplerVelocity(const cVector3 dvelocity) = 0;
|
||||
//!Seek through the audio stream
|
||||
virtual void seek(float secs) = 0;
|
||||
//! Plays the source with the default or last set values
|
||||
virtual bool play() = 0;
|
||||
//! Plays the source in 2D mode
|
||||
virtual bool play2d(const bool& toLoop = false) = 0;
|
||||
//! Plays the source in 3D mode
|
||||
virtual bool play3d(const cVector3& position, const float& soundstr = 1.0 , const bool& toLoop = false) = 0;
|
||||
|
||||
//! Pauses playback of the sound source
|
||||
virtual void pause() = 0;
|
||||
//! Stops playback of the sound source
|
||||
virtual void stop() = 0;
|
||||
//! Controls whether the source should loop or not
|
||||
virtual void loop(const bool& toLoop) = 0;
|
||||
//! Seeks through the audio stream to a specific spot
|
||||
/** Note: May not be supported by all codecs
|
||||
\param seconds: Number of seconds from the start of the audio stream to seek to
|
||||
\return True on success, False if the codec does not support seeking. */
|
||||
virtual bool seek(const float& seconds) = 0;
|
||||
|
||||
//! Normally called every frame by the audio manager to update the internal buffers
|
||||
//! Note: For internal use only.
|
||||
virtual bool update() = 0;
|
||||
//! Releases all resources used by the audio source, normally used to clean up before deletion
|
||||
//! Note: For internal use only.
|
||||
virtual void release() = 0;
|
||||
|
||||
//! Returns if the source is ready to be used
|
||||
virtual const bool isValid() const = 0;
|
||||
//! Returns if the source is playing
|
||||
virtual const bool isPlaying() const = 0;
|
||||
//! Returns if the source is paused
|
||||
virtual const bool isPaused() const = 0;
|
||||
//! Returns if the source is stopped
|
||||
virtual const bool isStopped() const = 0;
|
||||
//! Returns if the source is looping
|
||||
virtual const bool isLooping() const = 0;
|
||||
|
||||
//! Sets the position of the source in 3D space
|
||||
virtual void setPosition(const cVector3& position) = 0;
|
||||
//! Sets the current velocity of the source for doppler effects
|
||||
virtual void setVelocity(const cVector3& velocity) = 0;
|
||||
//! Sets the direction the source is facing
|
||||
virtual void setDirection(const cVector3& direction) = 0;
|
||||
|
||||
//! 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)
|
||||
virtual void setRolloffFactor(const float& rolloff) = 0;
|
||||
//! Sets how well the source carries over distance
|
||||
//! Same as setRolloffFactor(1.0f/soundstrength)
|
||||
//! Range: 0.0f to +inf (Default: 1.0f)
|
||||
virtual void setStrength(const float& soundstrength) = 0;
|
||||
//! Sets the distance from the source where attenuation will begin
|
||||
//! Range: 0.0f to +inf
|
||||
virtual void setMinDistance(const float& minDistance) = 0;
|
||||
//! Sets the distance from the source where attenuation will stop
|
||||
//! Range: 0.0f to +inf
|
||||
virtual void setMaxDistance(const float& maxDistance) = 0;
|
||||
|
||||
//! Sets the pitch of the source
|
||||
virtual void setPitch(const float& pitch) = 0;
|
||||
//! Sets the source volume before attenuation and other effects
|
||||
//! Range: 0.0f to +inf (Default: 1.0f)
|
||||
virtual void setVolume(const float& volume) = 0;
|
||||
//! Sets the minimum volume that the source can be attenuated to
|
||||
//! Range: 0.0f to +inf (Default: 0.0f)
|
||||
virtual void setMinVolume(const float& minVolume) = 0;
|
||||
//! Sets the maximum volume that the source can achieve
|
||||
//! Range: 0.0f to +inf (Default: 1.0f)
|
||||
virtual void setMaxVolume(const float& maxVolume) = 0;
|
||||
|
||||
//! Sets the angle of the inner sound cone of the source
|
||||
//! 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)
|
||||
virtual void setInnerConeAngle(const float& innerAngle) = 0;
|
||||
//! Sets the angle of the outer sound cone of the source
|
||||
//! 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)
|
||||
virtual void setOuterConeAngle(const float& outerAngle) = 0;
|
||||
//! Sets how much the volume of the source is scaled in the outer cone
|
||||
//! Range: 0.0f to +inf (Default: 0.0f)
|
||||
virtual void setOuterConeVolume(const float& outerVolume) = 0;
|
||||
|
||||
//! Sets the doppler strength, which enhances or diminishes the doppler effect
|
||||
//! Range: 0.0f to +inf (Default: 1.0f)
|
||||
virtual void setDopplerStrength(const float& dstrength) = 0;
|
||||
//! Overrides the doppler velocity vector
|
||||
virtual void setDopplerVelocity(const cVector3& dvelocity) = 0;
|
||||
|
||||
//!Returns the audio objects position
|
||||
virtual const cVector3& getPosition()const = 0;
|
||||
virtual const cVector3 getPosition() const = 0;
|
||||
//!Returns the audio objects velocity
|
||||
virtual const cVector3& getVelocity()const = 0;
|
||||
virtual const cVector3 getVelocity() const = 0;
|
||||
//!Returns the audio objects direction
|
||||
virtual const cVector3& getDirection()const = 0;
|
||||
//!Returns the audio objects doppler strength
|
||||
virtual const float& getDopplerStrength()const = 0;
|
||||
//!Returns the audio objects strength
|
||||
virtual const float& getStrength()const = 0;
|
||||
//!Returns the volume of the sound object
|
||||
virtual const float& getVolume()const = 0;
|
||||
//!Returns the pitch volume
|
||||
virtual const float& getPitch()const = 0;
|
||||
//!Returns if the sound object is looping
|
||||
virtual const bool& isLooping()const = 0;
|
||||
virtual const cVector3 getDirection() const = 0;
|
||||
|
||||
//!release the file handle
|
||||
virtual void release() = 0;
|
||||
//!pauses the audio file
|
||||
virtual void pause() = 0;
|
||||
//!controls altering of the looping to make it loop or not to.
|
||||
virtual void loop(bool loop) = 0;
|
||||
//!stops the audio file from playing
|
||||
virtual void stop() = 0;
|
||||
//! Returns the factor used in attenuating the source over distance
|
||||
virtual const float getRolloffFactor() const = 0;
|
||||
//! Returns the strength of the source
|
||||
virtual const float getStrength() const = 0;
|
||||
//! Returns the distance from the source where attenuation will begin
|
||||
virtual const float getMinDistance() const = 0;
|
||||
//! Returns the distance from the source where attenuation will stop
|
||||
virtual const float getMaxDistance() const = 0;
|
||||
|
||||
//!Returns the pitch of the source
|
||||
virtual const float getPitch() const = 0;
|
||||
//!Returns the source volume before attenuation and other effects
|
||||
virtual const float getVolume() const = 0;
|
||||
//! Returns the minimum volume that the source can be attenuated to
|
||||
virtual const float getMinVolume() const = 0;
|
||||
//! Returns the maximum volume that the source can achieve
|
||||
virtual const float getMaxVolume() const = 0;
|
||||
|
||||
//! Returns the angle of the inner sound cone of the source
|
||||
virtual const float getInnerConeAngle() const = 0;
|
||||
//! Returns the angle of the outer sound cone of the source
|
||||
virtual const float getOuterConeAngle() const = 0;
|
||||
//! Returns how much the volume of the source is scaled in the outer cone
|
||||
virtual const float getOuterConeVolume() const = 0;
|
||||
|
||||
//!Returns the doppler strength, which enhances or diminishes the doppler effect
|
||||
virtual const float getDopplerStrength() const = 0;
|
||||
//!Returns the override for the doppler velocity vector
|
||||
virtual const cVector3 getDopplerVelocity() const = 0;
|
||||
|
||||
//!play file
|
||||
virtual bool playback() = 0;
|
||||
//!check if source is playing
|
||||
virtual bool playing() = 0;
|
||||
//!update the stream
|
||||
virtual bool update() = 0;
|
||||
//!checks to make sure everything is ready to go
|
||||
virtual bool isvalid() = 0;
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue