caudio/Headers/cAudio.h

131 lines
3.6 KiB
C
Raw Normal View History

2009-06-21 05:24:30 +02:00
#ifndef CAUDIO_H_INCLUDED
#define CAUDIO_H_INCLUDED
#include <string>
#include <iostream>
2009-08-26 03:16:40 +02:00
#include <vector>
2009-06-21 05:24:30 +02:00
#include "AL/al.h"
#define BUFFER_SIZE ( 1024 * 32 )
#include "../include/IAudio.h"
2009-08-26 03:16:40 +02:00
#include "../Include/cVector3.h"
2009-06-21 05:24:30 +02:00
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
2009-08-26 03:16:40 +02:00
void play3d(cVector3 position, float soundstr = 1.0 , bool loop = false);
//!allows us to set the position or reset the position
2009-08-26 04:19:58 +02:00
void setPosition(const cVector3 position);
//!allows you to set the audio objects velocity
2009-08-26 04:19:58 +02:00
void setVelocity(const cVector3 velocity);
//!allows us to set the direction the audio should play in
2009-08-26 04:19:58 +02:00
void setDirection(const cVector3 direction);
//! Sets the audios pitch level
2009-08-26 04:19:58 +02:00
void setPitch(const float pitch);
//!allows us to set and reset the sound strenght
2009-08-26 04:19:58 +02:00
void setStrength(const float soundstrength);
//!Set the volume
2009-08-26 04:19:58 +02:00
void setVolume(const float volume);
//!Set the doppler strength
2009-08-26 04:19:58 +02:00
void setDopplerStrength(const float dstrength);
//!Set doppler velocity
2009-08-26 04:19:58 +02:00
void setDopplerVelocity(const cVector3 dvelocity);
//!Returns the audio objects position
2009-08-26 05:06:36 +02:00
const cVector3& getPosition()const;
2009-08-26 04:19:58 +02:00
//!Returns the audio objects velocity
2009-08-26 05:06:36 +02:00
const cVector3& getVelocity()const;
2009-08-26 04:19:58 +02:00
//!Returns the audio objects direction
2009-08-26 05:06:36 +02:00
const cVector3& getDirection()const;
2009-08-26 04:19:58 +02:00
//!Returns the audio objects doppler strength
2009-08-26 05:06:36 +02:00
const float& getDopplerStrength()const;
2009-08-26 04:19:58 +02:00
//!Returns the audio objects strength
2009-08-26 05:06:36 +02:00
const float& getStrength()const;
2009-08-26 04:19:58 +02:00
//!Returns the volume of the sound object
2009-08-26 05:06:36 +02:00
const float& getVolume()const;
2009-08-26 04:19:58 +02:00
//!Returns the pitch volume
2009-08-26 05:06:36 +02:00
const float& getPitch()const;
2009-08-26 04:19:58 +02:00
//!Returns if the sound object is looping
2009-08-26 05:06:36 +02:00
const bool& isLooping()const;
2009-08-26 04:19:58 +02:00
//!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();
2009-06-21 05:24:30 +02:00
//!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();
2009-06-21 05:24:30 +02:00
cAudio(IAudioDecoder* decoder);
~cAudio();
2009-06-21 05:24:30 +02:00
protected:
private:
//!empties the queue
void empty();
//!checks openal error state
void check();
//!reloads a buffer
bool stream(ALuint buffer);
//!stringify an error code
std::string errorString(int code);
2009-06-21 05:24:30 +02:00
//! front and back buffers
ALuint buffers[3];
//! audio source
ALuint source;
//! decoder pointer
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();
2009-08-26 03:16:40 +02:00
//! 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;
2009-08-26 04:19:58 +02:00
//! Stores the volume
float volume;
//! Stores the pitch
float pitch;
//! Stores doppler strength
float dstrength;
//! Stores the objects sound strength
float strength;
2009-06-21 05:24:30 +02:00
};
}
#endif //! CAUDIO_H_INCLUDED