Fixed problem with the msvc project not outputting a .lib file.
Updated tutorials to fix minor bugs and pathing issues. Also fixed crash bug on failure to create the audio object. Added msvc projects for all tutorials. Updated the listener class to be self contained and only handle stuff related to the OpenAL listener. It does NOT init OpenAL anymore, that has been moved to cAudioManager. Extended the listener class to support all settings that native OpenAL supports. Cleaned up cFileSource and fixed a crash bug on NULL file handle Fixed returning bad audio buffer chunk sizes from the cOggDecoder on errors in the ogg stream Seeking can now be down in fractions of a second now, changed the seconds field from int to float Fixed various odd formatting. Fixed potential crash bug in cMemorySource if memory could not be allocated. cMemorySource will no longer clear the buffer you give to it before filling it with data. This prevents an overwrite from happening in case of error but the user should provide a zeroed buffer to cMemorySource anyway for safety. Relative seeking is now supported by cOggDecoder.
This commit is contained in:
parent
ea195bce4d
commit
28a22c7f73
|
@ -12,7 +12,7 @@ int main(int argc, char* argv[])
|
|||
cAudio::IAudio* mysound;
|
||||
|
||||
//Some fancy text
|
||||
cout <<"cAudio 1.7.1 Tutorial 1: 2DSound\n";
|
||||
cout << "cAudio 1.7.1 Tutorial 1: 2DSound \n";
|
||||
|
||||
//Grap the cAudioManager
|
||||
cAudio::IAudioManager* manager = cAudio::getAudioManager();
|
||||
|
@ -20,14 +20,19 @@ int main(int argc, char* argv[])
|
|||
manager->init(argc,argv);
|
||||
//Create a IAudio object and load a sound from a file
|
||||
mysound = manager->createFromFile("bling","../../bin/bling.ogg",true);
|
||||
//Set the IAudio Sound to play2d and loop
|
||||
mysound->play2d(true);
|
||||
|
||||
while(mysound->playing()){
|
||||
//Playback sound
|
||||
manager->update();
|
||||
if(mysound)
|
||||
{
|
||||
mysound->setVolume(0.5);
|
||||
//Set the IAudio Sound to play2d and loop
|
||||
mysound->play2d(true);
|
||||
|
||||
}
|
||||
while(mysound->playing())
|
||||
{
|
||||
//Playback sound
|
||||
manager->update();
|
||||
}
|
||||
}
|
||||
|
||||
//Delete all IAudio sounds
|
||||
manager->release();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//****************************************************************
|
||||
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
//Include IAudioManager so we can easily work with cAudio
|
||||
#include "../../include/IAudioManager.h"
|
||||
//Include IAudio so we can create cAudio objects
|
||||
|
@ -16,27 +17,37 @@ int main(int argc, char* argv[])
|
|||
//To make visual studio happy
|
||||
cAudio::IAudio* mysound;
|
||||
//Some fancy text
|
||||
cout <<"cAudio 1.7.1 Tutorial 2: 3dSound\n";
|
||||
cout << "cAudio 1.7.1 Tutorial 2: 3dSound \n";
|
||||
//Hold audio source x position
|
||||
float x = 0;
|
||||
//Grap the cAudioManager
|
||||
cAudio::IAudioManager* manager = cAudio::getAudioManager();
|
||||
//Init the cAudio Engine
|
||||
manager->init(argc,argv);
|
||||
manager->setListenerPos(0.0,0.0,0.0);
|
||||
|
||||
//Grab the listener object, which allows us to manipulate where "we" are in the world
|
||||
//It's useful to bind this to a camera if you are using a 3d graphics engine
|
||||
cAudio::IListener* listener = manager->getListener();
|
||||
|
||||
//Create a IAudio object and load a sound from a file
|
||||
mysound = manager->createFromFile("bling","bling.ogg",true);
|
||||
mysound = manager->createFromFile("bling","../../bin/bling.ogg",true);
|
||||
|
||||
//Set the IAudio Sound to play3d and loop
|
||||
//play3d takes 4 arguments play3d(toloop,x,y,z,strength)
|
||||
mysound->play3d(true,0.0,0.0,0.0,0.1);
|
||||
if(mysound && listener)
|
||||
{
|
||||
listener->setPosition(0,0,0);
|
||||
mysound->play3d(true,0.0,0.0,0.0,0.1);
|
||||
|
||||
while(mysound->playing()){
|
||||
//Playback sound
|
||||
x+=0.0001;
|
||||
mysound->setPosition(x,0.0,0.0);
|
||||
manager->update();
|
||||
|
||||
}
|
||||
while(mysound->playing())
|
||||
{
|
||||
//Playback sound
|
||||
x+=0.001f * 0.017453293f; //0.001 degrees a frame
|
||||
float realX = sinf(x)*10.f;
|
||||
mysound->setPosition(realX,0.0,-5.0);
|
||||
manager->update();
|
||||
}
|
||||
}
|
||||
|
||||
//Delete all IAudio sounds
|
||||
manager->release();
|
||||
|
|
|
@ -18,25 +18,28 @@ using namespace std;
|
|||
int main(int argc, char* argv[])
|
||||
{
|
||||
//Make visual studio happy
|
||||
cAudio::IAudio* mysound;
|
||||
cAudio::IAudio* mysound = 0x0;
|
||||
//Some fancy text
|
||||
cout <<"cAudio 1.7.1 Tutorial 3: MemoryPlayback\n";
|
||||
cout << "cAudio 1.7.1 Tutorial 3: MemoryPlayback \n";
|
||||
//Grap the cAudioManager
|
||||
cAudio::IAudioManager* manager = cAudio::getAudioManager();
|
||||
//Init the cAudio Engine
|
||||
manager->init(argc,argv);
|
||||
manager->setListenerPos(0.0,0.0,0.0);
|
||||
//Create a IAudio object and load a sound from memory. using the bling array and bling size generated by bin2h.
mysound = manager->createFromMemory("bling",(const char*)bling,bling_size,"wav");
|
||||
//Set the IAudio Sound to play2d and loop
|
||||
mysound->play2d(true);
|
||||
|
||||
|
||||
while(mysound->playing()){
|
||||
|
||||
//Playback sound
|
||||
manager->update();
|
||||
//Create a IAudio object and load a sound from memory. using the bling array and bling size generated by bin2h.
|
||||
mysound = manager->createFromMemory("bling",(const char*)bling,bling_size,"wav");
|
||||
|
||||
}
|
||||
if(mysound)
|
||||
{
|
||||
//Set the IAudio Sound to play2d and loop
|
||||
mysound->play2d(true);
|
||||
|
||||
while(mysound->playing())
|
||||
{
|
||||
//Playback sound
|
||||
manager->update();
|
||||
}
|
||||
}
|
||||
|
||||
//Delete all IAudio sounds
|
||||
manager->release();
|
||||
|
|
138
Headers/cAudio.h
138
Headers/cAudio.h
|
@ -13,79 +13,79 @@ 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(bool loop = false, float x = 0.0, float y = 0.0, float z = 0.0, float soundstr = 1.0);
|
||||
//!allows us to set the position or reset the position
|
||||
void setPosition(float posx,float posy,float posz);
|
||||
//!allows you to set the audio objects velocity
|
||||
void setVelocity(float velx,float vely,float velz);
|
||||
//!allows us to set the direction the audio should play in / move
|
||||
void setDirection(float dirx,float diry,float dirz);
|
||||
//! Sets the audios pitch level
|
||||
void setPitch(float pitch);
|
||||
//!allows us to set and reset the sound strenght
|
||||
void setStrength(float soundstrength);
|
||||
//!Set the volume
|
||||
void setVolume(float volume);
|
||||
//!Set the doppler strength
|
||||
void setDopplerStrength(float doop);
|
||||
//!Set doppler velocity
|
||||
void setDopplerVelocity(float doopx,float doopy,float doopz);
|
||||
//!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();
|
||||
//! 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(bool loop = false, float x = 0.0, float y = 0.0, float z = 0.0, float soundstr = 1.0);
|
||||
//!allows us to set the position or reset the position
|
||||
void setPosition(float posx,float posy,float posz);
|
||||
//!allows you to set the audio objects velocity
|
||||
void setVelocity(float velx,float vely,float velz);
|
||||
//!allows us to set the direction the audio should play in / move
|
||||
void setDirection(float dirx,float diry,float dirz);
|
||||
//! Sets the audios pitch level
|
||||
void setPitch(float pitch);
|
||||
//!allows us to set and reset the sound strenght
|
||||
void setStrength(float soundstrength);
|
||||
//!Set the volume
|
||||
void setVolume(float volume);
|
||||
//!Set the doppler strength
|
||||
void setDopplerStrength(float doop);
|
||||
//!Set doppler velocity
|
||||
void setDopplerVelocity(float doopx,float doopy,float doopz);
|
||||
//!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 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();
|
||||
|
||||
cAudio(IAudioDecoder* decoder);
|
||||
~cAudio();
|
||||
cAudio(IAudioDecoder* decoder);
|
||||
~cAudio();
|
||||
|
||||
protected:
|
||||
//!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);
|
||||
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);
|
||||
|
||||
private:
|
||||
//! 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();
|
||||
//! 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();
|
||||
};
|
||||
}
|
||||
#endif //! CAUDIO_H_INCLUDED
|
||||
|
|
|
@ -15,50 +15,46 @@ namespace cAudio
|
|||
class cAudioManager : public IAudioManager
|
||||
{
|
||||
public:
|
||||
//!Inits the audio manager calling the alut/etc start ups
|
||||
void init(int argc,char* argv[]);
|
||||
//!Shuts everything down
|
||||
void shutDown();
|
||||
//!Creates the cAudio object
|
||||
IAudio* createFromFile(const std::string& identifier,const std::string& file,bool stream = false);
|
||||
//!Loads ogg from memory or virtual file system
|
||||
IAudio* createFromMemory(const std::string& identifier, const char* data, size_t length, std::string ext);
|
||||
//!Register Audio Codec
|
||||
void registerAudioDecoder(IAudioDecoderFactory* factory, std::string extension);
|
||||
//!Allows you to set the listener position
|
||||
void setListenerPos(float x,float y,float z);
|
||||
//!Set Listener Orientation
|
||||
void setListenerOrientation(float ux,float uy,float uz);
|
||||
//!Updates the cAudio playback
|
||||
void update();
|
||||
//!Gets you the cAudio object you want
|
||||
IAudio *getSound(std::string identifier);
|
||||
//!Releases "ALL" cAudio objects
|
||||
void release();
|
||||
//!Inits the audio manager calling the alut/etc start ups
|
||||
void init(int argc,char* argv[]);
|
||||
//!Shuts everything down
|
||||
void shutDown();
|
||||
//!Creates the cAudio object
|
||||
IAudio* createFromFile(const std::string& identifier,const std::string& file,bool stream = false);
|
||||
//!Loads ogg from memory or virtual file system
|
||||
IAudio* createFromMemory(const std::string& identifier, const char* data, size_t length, std::string ext);
|
||||
//!Register Audio Codec
|
||||
void registerAudioDecoder(IAudioDecoderFactory* factory, std::string extension);
|
||||
//!Allows you to set the listener position (DEPRECIATED! USE getListener() INSTEAD!)
|
||||
void setListenerPos(float x,float y,float z);
|
||||
//!Set Listener Orientation (DEPRECIATED! USE getListener() INSTEAD!)
|
||||
void setListenerOrientation(float ux,float uy,float uz);
|
||||
//!Updates the cAudio playback
|
||||
void update();
|
||||
//!Gets you the cAudio object you want
|
||||
IAudio *getSound(std::string identifier);
|
||||
//!Releases "ALL" cAudio objects
|
||||
void release();
|
||||
|
||||
static cAudioManager* Instance()
|
||||
{
|
||||
return &m_cAudioManager;
|
||||
}
|
||||
virtual IListener* getListener() { return &initlistener; }
|
||||
|
||||
protected:
|
||||
cAudioManager(){ }
|
||||
static cAudioManager* Instance()
|
||||
{
|
||||
return &m_cAudioManager;
|
||||
}
|
||||
|
||||
private:
|
||||
//!Global cAudioManager
|
||||
static cAudioManager m_cAudioManager;
|
||||
//!The map that holds the cAudio objects
|
||||
std::map<std::string, IAudio*> audiomap;
|
||||
//!Decoder map that holds all decoders by file extension
|
||||
std::map<std::string, IAudioDecoderFactory*> decodermap;
|
||||
//!The listener object
|
||||
cListener initlistener;
|
||||
//!The listener X Coordinate
|
||||
float listenerX;
|
||||
//!The listener Y Coordinate
|
||||
float listenerY;
|
||||
//!THe listener Z Coordinate
|
||||
float listenerZ;
|
||||
protected:
|
||||
cAudioManager(){ }
|
||||
|
||||
private:
|
||||
//!Global cAudioManager
|
||||
static cAudioManager m_cAudioManager;
|
||||
//!The map that holds the cAudio objects
|
||||
std::map<std::string, IAudio*> audiomap;
|
||||
//!Decoder map that holds all decoders by file extension
|
||||
std::map<std::string, IAudioDecoderFactory*> decodermap;
|
||||
//!The listener object
|
||||
cListener initlistener;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -31,15 +31,13 @@ class cFileSource : public IDataSource
|
|||
virtual bool seek(int amount, bool relative);
|
||||
|
||||
protected:
|
||||
//!File Stream
|
||||
std::ifstream File;
|
||||
//!Hold if valid
|
||||
bool Valid;
|
||||
//!Holds file size
|
||||
//!Hold if valid
|
||||
bool Valid;
|
||||
//!Holds file size
|
||||
int Filesize;
|
||||
//!File stream
|
||||
FILE* pFile;
|
||||
private:
|
||||
//!File stream
|
||||
FILE* pFile;
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -1,84 +1,58 @@
|
|||
#ifndef CLISTENER_H_INCLUDED
|
||||
#define CLISTENER_H_INCLUDED
|
||||
#include <AL/al.h>
|
||||
#include <AL/alut.h>
|
||||
//!#include <AL/alext.h>
|
||||
//!#include <AL/efx.h>
|
||||
#include <iostream>
|
||||
#define LOAD_AL_FUNC(x) (x = (typeof(x))alGetProcAddress(#x))
|
||||
|
||||
#include "../include/IListener.h"
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
class cListener
|
||||
class cListener : public IListener
|
||||
{
|
||||
public:
|
||||
cListener static &getInstance()
|
||||
{
|
||||
static cListener This;
|
||||
return This;
|
||||
}
|
||||
cListener() : Direction(0.f, 0.f, -1.f),
|
||||
UpVector(0.f, 1.f, 0.f),
|
||||
MasterGain(1.f) {}
|
||||
virtual ~cListener() {}
|
||||
|
||||
//!Sets the listeners position
|
||||
void setPosition(ALfloat x,ALfloat y, ALfloat z)
|
||||
{
|
||||
alListener3f(AL_POSITION,x,y,z);
|
||||
}
|
||||
//!Sets the listeners orientation
|
||||
void setOrientation(ALfloat x,ALfloat y,ALfloat z,ALfloat upx,ALfloat upy,ALfloat upz)
|
||||
{
|
||||
ALfloat orientation[6] = {x,y,z,upx,upy,upz};
|
||||
alListenerfv(AL_ORIENTATION,orientation);
|
||||
}
|
||||
//!Inits Openal
|
||||
static void initaudio(int argc,char* argv[])
|
||||
{
|
||||
alutInit(&argc,argv);
|
||||
/*
|
||||
ALCcontext *Context;
|
||||
ALCdevice *Device;
|
||||
ALint attribs[4] = {0};
|
||||
ALCint iSends = 0;
|
||||
LPALGENEFFECTS alGenEffects;
|
||||
LPALDELETEEFFECTS alDeleteEffects;
|
||||
LPALISEFFECT alIsEffect;
|
||||
//!Sets the position of the listener
|
||||
//!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);
|
||||
|
||||
Device = alcOpenDevice(NULL);
|
||||
//!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);
|
||||
|
||||
//!Query for effect extention
|
||||
if(alcIsExtensionPresent(Device,"ALC_EXT_EFX") == AL_FALSE){
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//!Use context creation hint to request 4 axiliary sends per source
|
||||
attribs[0] = ALC_MAX_AUXILIARY_SENDS;
|
||||
attribs[1] = 4;
|
||||
attribs[2] = 0;
|
||||
|
||||
Context = alcCreateContext(Device,attribs);
|
||||
|
||||
if(!Context)
|
||||
return;
|
||||
|
||||
//!activate context
|
||||
|
||||
alcMakeContextCurrent(Context);
|
||||
|
||||
//!retrive Actual number aux sends avaliable per source
|
||||
alcGetIntegerv(Device,ALC_MAX_AUXILIARY_SENDS,1,&iSends);
|
||||
|
||||
//!Get the effect extention function pointers
|
||||
LOAD_AL_FUNC(alGenEffects);
|
||||
LOAD_AL_FUNC(alDeleteEffects);
|
||||
LOAD_AL_FUNC(alIsEffect);
|
||||
|
||||
*/
|
||||
}
|
||||
//!Shutsdown openal
|
||||
static void shutdownaudio()
|
||||
{
|
||||
alutExit();
|
||||
}
|
||||
//!Returns the current position of the listener
|
||||
virtual cVector3 getPosition(void) const { return Position; }
|
||||
//!Returns the current direction of the listener
|
||||
virtual cVector3 getDirection(void) const { return Direction; }
|
||||
//!Returns the current up vector of the listener
|
||||
virtual cVector3 getUpVector(void) const { return UpVector; }
|
||||
//!Returns the current velocity of the listener
|
||||
virtual cVector3 getVelocity(void) const { return Velocity; }
|
||||
//!Returns the global volume modifier for all sources
|
||||
virtual float getMasterVolume(void) const { return MasterGain; }
|
||||
protected:
|
||||
cVector3 Position;
|
||||
cVector3 Direction;
|
||||
cVector3 UpVector;
|
||||
cVector3 Velocity;
|
||||
float MasterGain;
|
||||
private:
|
||||
};
|
||||
}
|
||||
#endif //! CLISTENER_H_INCLUDED
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <vorbis/codec.h>
|
||||
#include <vorbis/vorbisenc.h>
|
||||
#include <vorbis/vorbisfile.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
|
@ -34,17 +33,17 @@ namespace cAudio
|
|||
virtual bool setPosition(int position, bool relative);
|
||||
|
||||
//!If seeking is supported, will seek the stream to seconds
|
||||
virtual bool seek(int seconds,bool relative);
|
||||
virtual bool seek(float seconds,bool relative);
|
||||
|
||||
protected:
|
||||
//!Callbacks used for read memory
|
||||
ov_callbacks vorbisCallbacks;
|
||||
//!some formatting data
|
||||
vorbis_info* vorbisInfo;
|
||||
//!User Comments
|
||||
vorbis_comment* vorbisComment;
|
||||
//!Stream handle
|
||||
OggVorbis_File oggStream;
|
||||
ov_callbacks vorbisCallbacks;
|
||||
//!some formatting data
|
||||
vorbis_info* vorbisInfo;
|
||||
//!User Comments
|
||||
vorbis_comment* vorbisComment;
|
||||
//!Stream handle
|
||||
OggVorbis_File oggStream;
|
||||
bool seekable;
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#include <string>
|
||||
|
||||
//!Grabs the current extention of a given string.
|
||||
std::string getExt(const std::string& filename){
|
||||
std::string getExt(const std::string& filename)
|
||||
{
|
||||
if(filename.find_last_of(".") == std::string::npos) return filename;
|
||||
return filename.substr(filename.find_last_of(".") + 1, filename.length()-filename.find_last_of(".")-1);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define CWAVDECODER_H_INCLUDED
|
||||
|
||||
#include "../include/IAudioDecoder.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
|
@ -30,7 +29,7 @@ namespace cAudio
|
|||
virtual bool setPosition(int position, bool relative);
|
||||
|
||||
//!If seeking is supported, will seek the stream to seconds
|
||||
virtual bool seek(int seconds,bool relative);
|
||||
virtual bool seek(float seconds,bool relative);
|
||||
|
||||
private:
|
||||
int mChunkSize;
|
||||
|
@ -42,8 +41,6 @@ namespace cAudio
|
|||
short mBlockAlign;
|
||||
short mBitsPerSample;
|
||||
int mDataSize;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,13 @@
|
|||
#include "../Headers/cOggAudioDecoderFactory.h"
|
||||
#include "../Headers/cWavAudioDecoderFacotry.h"
|
||||
|
||||
#include <AL/al.h>
|
||||
#include <AL/alut.h>
|
||||
//!#include <AL/alext.h>
|
||||
//!#include <AL/efx.h>
|
||||
#include <iostream>
|
||||
#define LOAD_AL_FUNC(x) (x = (typeof(x))alGetProcAddress(#x))
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
CAUDIO_API IAudioManager* getAudioManager(void)
|
||||
|
@ -16,11 +23,46 @@ namespace cAudio
|
|||
//!Initialize the listener,openal,and mikmod
|
||||
void cAudioManager::init(int argc,char* argv[])
|
||||
{
|
||||
initlistener = cListener::getInstance();
|
||||
initlistener.initaudio(argc,argv);
|
||||
listenerX = 0.0;
|
||||
listenerY = 0.0;
|
||||
listenerZ = 0.0;
|
||||
alutInit(&argc,argv);
|
||||
/*
|
||||
ALCcontext *Context;
|
||||
ALCdevice *Device;
|
||||
ALint attribs[4] = {0};
|
||||
ALCint iSends = 0;
|
||||
LPALGENEFFECTS alGenEffects;
|
||||
LPALDELETEEFFECTS alDeleteEffects;
|
||||
LPALISEFFECT alIsEffect;
|
||||
|
||||
Device = alcOpenDevice(NULL);
|
||||
|
||||
//!Query for effect extention
|
||||
if(alcIsExtensionPresent(Device,"ALC_EXT_EFX") == AL_FALSE){
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//!Use context creation hint to request 4 axiliary sends per source
|
||||
attribs[0] = ALC_MAX_AUXILIARY_SENDS;
|
||||
attribs[1] = 4;
|
||||
attribs[2] = 0;
|
||||
|
||||
Context = alcCreateContext(Device,attribs);
|
||||
|
||||
if(!Context)
|
||||
return;
|
||||
|
||||
//!activate context
|
||||
|
||||
alcMakeContextCurrent(Context);
|
||||
|
||||
//!retrive Actual number aux sends avaliable per source
|
||||
alcGetIntegerv(Device,ALC_MAX_AUXILIARY_SENDS,1,&iSends);
|
||||
|
||||
//!Get the effect extention function pointers
|
||||
LOAD_AL_FUNC(alGenEffects);
|
||||
LOAD_AL_FUNC(alDeleteEffects);
|
||||
LOAD_AL_FUNC(alIsEffect);
|
||||
*/
|
||||
|
||||
registerAudioDecoder(new cOggAudioDecoderFactory, "ogg");
|
||||
registerAudioDecoder(new cWavAudioDecoderFactory, "wav");
|
||||
|
@ -110,14 +152,16 @@ namespace cAudio
|
|||
{
|
||||
i->second->release();
|
||||
delete i->second;
|
||||
audiomap.erase(i++);
|
||||
i++;
|
||||
}
|
||||
audiomap.clear();
|
||||
std::map<std::string, IAudioDecoderFactory*>::iterator it = decodermap.begin();
|
||||
while ( it != decodermap.end())
|
||||
{
|
||||
delete it->second;
|
||||
decodermap.erase(it++);
|
||||
it++;
|
||||
}
|
||||
decodermap.clear();
|
||||
}
|
||||
|
||||
//!Updates all audiosources created
|
||||
|
@ -144,22 +188,19 @@ namespace cAudio
|
|||
//!Shuts down cAudio. Deletes all audio sources in process
|
||||
void cAudioManager::shutDown()
|
||||
{
|
||||
initlistener.shutdownaudio;
|
||||
alutExit();
|
||||
}
|
||||
|
||||
//!Sets the listeners position.
|
||||
void cAudioManager::setListenerPos(float x,float y,float z)
|
||||
{
|
||||
initlistener.setPosition(x,y,z);
|
||||
listenerX = x;
|
||||
listenerY = y;
|
||||
listenerZ = z;
|
||||
}
|
||||
|
||||
//!Sets the listener orientation
|
||||
void cAudioManager::setListenerOrientation(float ux,float uy,float uz)
|
||||
{
|
||||
initlistener.setOrientation(listenerX,listenerY,listenerZ,ux,uy,uz);
|
||||
initlistener.setUpVector(ux,uy,uz);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ cFileSource::cFileSource(const std::string& filename) : pFile(NULL), Valid(false
|
|||
|
||||
cFileSource::~cFileSource()
|
||||
{
|
||||
fclose(pFile);
|
||||
if(pFile)
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
//!Returns true if the FileSource is valid
|
||||
|
|
|
@ -1 +1,41 @@
|
|||
#include "../Headers/cListener.h"
|
||||
#include <AL/al.h>
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
void cListener::setPosition(const cVector3 pos)
|
||||
{
|
||||
Position = pos;
|
||||
alListener3f(AL_POSITION, Position.x, Position.y, Position.z);
|
||||
}
|
||||
void cListener::setDirection(const cVector3 dir)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Velocity = vel;
|
||||
alListener3f(AL_VELOCITY, Velocity.x, Velocity.y, Velocity.z);
|
||||
}
|
||||
void cListener::setMasterVolume(const float volume)
|
||||
{
|
||||
MasterGain = volume;
|
||||
alListenerf(AL_GAIN, MasterGain);
|
||||
}
|
||||
void cListener::move(const cVector3 pos)
|
||||
{
|
||||
Velocity = pos - Position;
|
||||
Position = pos;
|
||||
|
||||
alListener3f(AL_POSITION, Position.x, Position.y, Position.z);
|
||||
alListener3f(AL_VELOCITY, Velocity.x, Velocity.y, Velocity.z);
|
||||
}
|
||||
};
|
|
@ -13,13 +13,15 @@ cMemorySource::cMemorySource(const void* data, int size, bool copy) : Data(NULL)
|
|||
if(copy)
|
||||
{
|
||||
Data = new char[Size];
|
||||
memcpy(Data, data, Size);
|
||||
if(Data)
|
||||
memcpy(Data, data, Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
Data = (char*)data;
|
||||
}
|
||||
Valid = true;
|
||||
if(Data)
|
||||
Valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +52,7 @@ int cMemorySource::getSize()
|
|||
int cMemorySource::read(void* output, int size)
|
||||
{
|
||||
|
||||
memset(output, 0, size);
|
||||
//memset(output, 0, size);
|
||||
if(Pos+size <= Size)
|
||||
{
|
||||
memcpy(output, Data+Pos, size);
|
||||
|
|
|
@ -73,14 +73,15 @@ namespace cAudio
|
|||
//!Returns if vorbis file is seekable
|
||||
bool cOggDecoder::isSeekingSupported()
|
||||
{
|
||||
return ov_seekable(&oggStream);
|
||||
return (ov_seekable(&oggStream)!=0);
|
||||
}
|
||||
|
||||
//!Reads the vorbis data
|
||||
int cOggDecoder::readAudioData(void* output, int amount)
|
||||
{
|
||||
int temp;
|
||||
return ov_read(&oggStream,(char*)output,amount,0,2,1,&temp);
|
||||
int temp = 0;
|
||||
int result = ov_read(&oggStream,(char*)output,amount,0,2,1,&temp);
|
||||
return (result < 0) ? 0 : result;
|
||||
}
|
||||
|
||||
//!Sets the postion for vorbis data reader
|
||||
|
@ -88,22 +89,25 @@ namespace cAudio
|
|||
{
|
||||
if(ov_seekable(&oggStream))
|
||||
{
|
||||
ov_raw_seek(&oggStream,position);
|
||||
return true;
|
||||
return (ov_raw_seek(&oggStream,position)==0);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//!Seeks the vorbis data
|
||||
bool cOggDecoder::seek(int seconds,bool relative)
|
||||
bool cOggDecoder::seek(float seconds, bool relative)
|
||||
{
|
||||
int oldamount = ov_time_total(&oggStream,-1);
|
||||
|
||||
if(ov_seekable(&oggStream))
|
||||
{
|
||||
ov_time_seek(&oggStream,seconds);
|
||||
if(relative)
|
||||
{
|
||||
float curtime = ov_time_tell(&oggStream);
|
||||
return (ov_time_seek(&oggStream,curtime+seconds)==0);
|
||||
}
|
||||
else
|
||||
return (ov_time_seek(&oggStream,seconds)==0);
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,21 +17,22 @@ namespace cAudio{
|
|||
Stream->seek(40,false);
|
||||
Stream->read(&mDataSize,sizeof(int));
|
||||
Stream->seek(44,false);
|
||||
|
||||
//Double the sampleRate to fix a bug with half-time speed
|
||||
mSampleRate += mSampleRate;
|
||||
}
|
||||
|
||||
cWavDecoder::~cWavDecoder()
|
||||
{
|
||||
mChunkSize = NULL;
|
||||
mSubChunk1Size = NULL;
|
||||
mFormat = NULL;
|
||||
mChannels = NULL;
|
||||
mSampleRate = NULL;
|
||||
mByteRate = NULL;
|
||||
mBlockAlign = NULL;
|
||||
mBitsPerSample = NULL;
|
||||
mDataSize = NULL;
|
||||
|
||||
mChunkSize = 0;
|
||||
mSubChunk1Size = 0;
|
||||
mFormat = 0;
|
||||
mChannels = 0;
|
||||
mSampleRate = 0;
|
||||
mByteRate = 0;
|
||||
mBlockAlign = 0;
|
||||
mBitsPerSample = 0;
|
||||
mDataSize = 0;
|
||||
}
|
||||
|
||||
//!Returns wav channel format
|
||||
|
@ -71,7 +72,7 @@ namespace cAudio{
|
|||
}
|
||||
|
||||
//!Seeks wav data
|
||||
bool cWavDecoder::seek(int seconds,bool relative)
|
||||
bool cWavDecoder::seek(float seconds,bool relative)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<ActiveTarget name="ALL" />
|
||||
<File name="include\IAudioManager.h" open="1" top="1" tabpos="1">
|
||||
<Cursor position="312" topLine="1" />
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
|
18
cAudio.sln
18
cAudio.sln
|
@ -3,6 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 10.00
|
|||
# Visual C++ Express 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}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tutorial2_3DSound", "Examples\Tutorial2_3DSound\Tutorial2_3DSound.vcproj", "{96052488-DB19-492E-88F6-D14AFD61E4F9}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tutorial3_MemoryPlayback", "Examples\Tutorial3_MemoryPlayback\Tutorial3_MemoryPlayback.vcproj", "{FEA3B340-BBB2-4AFB-AF31-3962A0F3F2C6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -13,6 +19,18 @@ Global
|
|||
{ACD6C202-85D4-44F5-83BF-6577A074F655}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{ACD6C202-85D4-44F5-83BF-6577A074F655}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{ACD6C202-85D4-44F5-83BF-6577A074F655}.Release|Win32.Build.0 = Release|Win32
|
||||
{D7A934F9-003B-47F7-AAD6-F360A4D41B9B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D7A934F9-003B-47F7-AAD6-F360A4D41B9B}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D7A934F9-003B-47F7-AAD6-F360A4D41B9B}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D7A934F9-003B-47F7-AAD6-F360A4D41B9B}.Release|Win32.Build.0 = Release|Win32
|
||||
{96052488-DB19-492E-88F6-D14AFD61E4F9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{96052488-DB19-492E-88F6-D14AFD61E4F9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{96052488-DB19-492E-88F6-D14AFD61E4F9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{96052488-DB19-492E-88F6-D14AFD61E4F9}.Release|Win32.Build.0 = Release|Win32
|
||||
{FEA3B340-BBB2-4AFB-AF31-3962A0F3F2C6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{FEA3B340-BBB2-4AFB-AF31-3962A0F3F2C6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{FEA3B340-BBB2-4AFB-AF31-3962A0F3F2C6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{FEA3B340-BBB2-4AFB-AF31-3962A0F3F2C6}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="2"
|
||||
UseOfMFC="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -41,7 +41,7 @@
|
|||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=".\dependencies\Headers;.\dependencies\Headers\alut;.\dependencies\Headers\al"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CAUDIO_EXPORTS;"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CAUDIO_EXPORTS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
|
@ -64,8 +64,9 @@
|
|||
AdditionalDependencies="OpenAL32.lib alut.lib ogg_static.lib vorbis_static.lib vorbisenc_static.lib vorbisfile_static.lib"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=".\dependencies\Libs\windows"
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
|
@ -205,6 +206,10 @@
|
|||
RelativePath=".\Headers\cUtils.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Headers\cVector3.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Headers\cWavAudioDecoderFacotry.h"
|
||||
>
|
||||
|
|
|
@ -8,50 +8,51 @@ namespace cAudio
|
|||
class IAudio
|
||||
{
|
||||
public:
|
||||
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(bool loop = false, float x = 0.0, float y = 0.0, float z = 0.0, float soundstr = 1.0) = 0;
|
||||
//!allows us to set the position or reset the position
|
||||
virtual void setPosition(float posx,float posy,float posz) = 0;
|
||||
//!allows you to set the audio objects velocity
|
||||
virtual void setVelocity(float velx,float vely,float velz) = 0;
|
||||
//!allows us to set the direction the audio should play in / move
|
||||
virtual void setDirection(float dirx,float diry,float dirz) = 0;
|
||||
//! Sets the audios pitch level
|
||||
virtual void setPitch(float pitch) = 0;
|
||||
//!allows us to set and reset the sound strength
|
||||
virtual void setStrength(float soundstrength) = 0;
|
||||
//! Set the volume
|
||||
virtual void setVolume(float volume) = 0;
|
||||
//!Set the doppler strength
|
||||
virtual void setDopplerStrength(float doop) = 0;
|
||||
//!Set the doppler velocity
|
||||
virtual void setDopplerVelocity(float doopx,float doopy,float doopz) = 0;
|
||||
//!Seek through the audio stream
|
||||
virtual void seek(float secs) = 0;
|
||||
IAudio() {}
|
||||
virtual ~IAudio() {}
|
||||
|
||||
//!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;
|
||||
|
||||
//!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;
|
||||
//! 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(bool loop = false, float x = 0.0, float y = 0.0, float z = 0.0, float soundstr = 1.0) = 0;
|
||||
//!allows us to set the position or reset the position
|
||||
virtual void setPosition(float posx,float posy,float posz) = 0;
|
||||
//!allows you to set the audio objects velocity
|
||||
virtual void setVelocity(float velx,float vely,float velz) = 0;
|
||||
//!allows us to set the direction the audio should play in / move
|
||||
virtual void setDirection(float dirx,float diry,float dirz) = 0;
|
||||
//! Sets the audios pitch level
|
||||
virtual void setPitch(float pitch) = 0;
|
||||
//!allows us to set and reset the sound strength
|
||||
virtual void setStrength(float soundstrength) = 0;
|
||||
//! Set the volume
|
||||
virtual void setVolume(float volume) = 0;
|
||||
//!Set the doppler strength
|
||||
virtual void setDopplerStrength(float doop) = 0;
|
||||
//!Set the doppler velocity
|
||||
virtual void setDopplerVelocity(float doopx,float doopy,float doopz) = 0;
|
||||
//!Seek through the audio stream
|
||||
virtual void seek(float secs) = 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;
|
||||
|
||||
//!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:
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ class IAudioDecoder
|
|||
virtual bool setPosition(int position, bool relative) = 0;
|
||||
|
||||
//!If seeking is supported, will seek the stream to seconds
|
||||
virtual bool seek(int seconds, bool relative) = 0;
|
||||
virtual bool seek(float seconds, bool relative) = 0;
|
||||
protected:
|
||||
IDataSource* Stream;
|
||||
};
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
#ifndef IAUDIOMANAGER_H
|
||||
#define IAUDIOMANAGER_H
|
||||
#include <string>
|
||||
#include "IListener.h"
|
||||
|
||||
#ifdef COMPILE_FOR_WINDOWS
|
||||
#ifndef CAUDIO_STATIC_LIB
|
||||
|
||||
#ifdef CAUDIO_EXPORTS
|
||||
#define CAUDIO_API __declspec(dllexport)
|
||||
#else
|
||||
#define CAUDIO_API//! __declspec(dllimport)
|
||||
#endif //! CAUDIO_API_EXPORT
|
||||
#endif // CAUDIO_EXPORTS
|
||||
|
||||
#else
|
||||
#define CAUDIO_API
|
||||
#endif _CAUDIO_API_STATIC_LIB_
|
||||
#else
|
||||
#define CAUDIO_API
|
||||
#endif
|
||||
#endif // CAUDIO_STATIC_LIB
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
class IAudio;
|
||||
|
@ -24,27 +24,30 @@ namespace cAudio
|
|||
class IAudioManager
|
||||
{
|
||||
public:
|
||||
//!Inits the audio manager calling the alut/etc start ups
|
||||
virtual void init(int argc,char* argv[]) = 0;
|
||||
//!Shuts everything down
|
||||
virtual void shutDown() = 0;
|
||||
//!Creates the cAudio object
|
||||
virtual IAudio* createFromFile(const std::string& identifier,const std::string& file,bool stream = false) = 0;
|
||||
//!Loads audio from memory or virtual file system
|
||||
virtual IAudio* createFromMemory(const std::string& identifier,const char* data, size_t length, std::string ext) = 0;
|
||||
//!Register Audio Codec
|
||||
virtual void registerAudioDecoder(IAudioDecoderFactory* factory, std::string extension) = 0;
|
||||
//!Allows you to set the listener position
|
||||
virtual void setListenerPos(float x,float y,float z) = 0;
|
||||
//!set the listeners orientation
|
||||
virtual void setListenerOrientation(float ux,float uy,float uz) = 0;
|
||||
//!Updates the cAudio playback
|
||||
virtual void update() = 0;
|
||||
//!Gets you the cAudio object you want
|
||||
virtual IAudio *getSound(std::string identifier) = 0;
|
||||
//!Releases "ALL" cAudio objects
|
||||
virtual void release() = 0;
|
||||
virtual ~IAudioManager() {}
|
||||
//!Inits the audio manager calling the alut/etc start ups
|
||||
virtual void init(int argc,char* argv[]) = 0;
|
||||
//!Shuts everything down
|
||||
virtual void shutDown() = 0;
|
||||
//!Creates the cAudio object
|
||||
virtual IAudio* createFromFile(const std::string& identifier,const std::string& file,bool stream = false) = 0;
|
||||
//!Loads audio from memory or virtual file system
|
||||
virtual IAudio* createFromMemory(const std::string& identifier,const char* data, size_t length, std::string ext) = 0;
|
||||
//!Register Audio Codec
|
||||
virtual void registerAudioDecoder(IAudioDecoderFactory* factory, std::string extension) = 0;
|
||||
//!Allows you to set the listener position
|
||||
virtual void setListenerPos(float x,float y,float z) = 0;
|
||||
//!set the listeners orientation
|
||||
virtual void setListenerOrientation(float ux,float uy,float uz) = 0;
|
||||
//!Updates the cAudio playback
|
||||
virtual void update() = 0;
|
||||
//!Gets you the cAudio object you want
|
||||
virtual IAudio *getSound(std::string identifier) = 0;
|
||||
//!Releases "ALL" cAudio objects
|
||||
virtual void release() = 0;
|
||||
|
||||
virtual IListener* getListener() = 0;
|
||||
|
||||
virtual ~IAudioManager() {}
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
|
|
@ -2,19 +2,51 @@
|
|||
#ifndef ILISTENER_H
|
||||
#define ILISTENER_H
|
||||
|
||||
#include "../Headers/cVector3.h"
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
class IListener
|
||||
{
|
||||
public:
|
||||
IListener() {}
|
||||
virtual ~IListener() {}
|
||||
|
||||
//!Sets the listeners position
|
||||
virtual void setPosition(ALfloat x,ALfloat y, ALfloat z) = 0;
|
||||
//!Sets the listeners orientation
|
||||
virtual void setOrientation(ALfloat x,ALfloat y,ALfloat z,ALfloat upx,ALfloat upy,ALfloat upz) = 0;
|
||||
//!Sets the position of the listener
|
||||
//!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
|
||||
virtual cVector3 getPosition(void) const = 0;
|
||||
//!Returns the current direction of the listener
|
||||
virtual cVector3 getDirection(void) const = 0;
|
||||
//!Returns the current up vector of the listener
|
||||
virtual cVector3 getUpVector(void) const = 0;
|
||||
//!Returns the current velocity of the listener
|
||||
virtual cVector3 getVelocity(void) const = 0;
|
||||
//!Returns the global volume modifier for all sources
|
||||
virtual float getMasterVolume(void) const = 0;
|
||||
|
||||
protected:
|
||||
IListener() {}
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue