00001 #ifndef CAUDIO_H_INCLUDED
00002 #define CAUDIO_H_INCLUDED
00003 #include <cstring>
00004 #include <iostream>
00005 #include <AL/al.h>
00006 #include <AL/alut.h>
00007 #include <ogg/ogg.h>
00008 #include <vorbis/codec.h>
00009 #include <vorbis/vorbisenc.h>
00010 #include <vorbis/vorbisfile.h>
00011
00012 #include <vector>
00013 #include "mikmod.h"
00014
00015
00016 struct SOggFile
00017 {
00018 char* dataPtr;
00019 int dataSize;
00020 int dataRead;
00021 };
00022
00023 #define BUFFER_SIZE ( 4096 * 8 )
00024 #include "IAudio.h"
00025 namespace cAudio
00026 {
00027 class cAudio : public IAudio
00028 {
00029 public:
00030 void open(const std::string& path);
00031 void openstream(const std::string& path);
00032 void play();
00033 void play2d(bool loop = false);
00034 void play3d(bool loop = false, float x = 0.0, float y = 0.0, float z = 0.0, float soundstr = 1.0);
00035 void setPosition(float posx,float posy,float posz);
00036 void setVelocity(float velx,float vely,float velz);
00037 void setDirection(float dirx,float diry,float dirz);
00038 void setPitch(float pitch);
00039 void setStrength(float soundstrength);
00040 void setVolume(float volume);
00041 void setDopplerStrength(float doop);
00042 void setDopplerVelocity(float doopx,float doopy,float doopz);
00043
00044 void release();
00045 void pause();
00046 void loop(bool loop);
00047 void stop();
00048
00049 bool playback();
00050 bool playing();
00051 bool update();
00052 bool isvalid();
00053
00054 static std::vector<cAudio*> thevector;
00055 cAudio();
00056
00057 protected:
00058
00059 void empty();
00060 void check();
00061
00062 bool stream(ALuint buffer);
00063 std::string errorString(int code);
00064
00065 private:
00066
00067 SOggFile oggMemoryFile;
00068 ov_callbacks vorbisCallbacks;
00069 FILE* oggFile;
00070 FILE *modFile;
00071 MODULE *modStream;
00072 vorbis_info* vorbisInfo;
00073 vorbis_comment* vorbisComment;
00074 OggVorbis_File oggStream;
00075
00076 ALuint buffers[3];
00077 ALuint source;
00078 ALenum format;
00079
00080 bool streaming;
00081 bool modfile;
00082 bool toloop;
00083 bool playaudio;
00084 bool pauseaudio;
00085
00086 std::string extension;
00087 };
00088 }
00089 #endif // CAUDIO_H_INCLUDED