00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00036 #ifndef AUDIOMANAGER_H_
00037 #define AUDIOMANAGER_H_
00038
00039 #include "FlyLegacy.h"
00040 #include <string>
00041 #include <map>
00042
00043 #ifdef HAVE_OPENAL
00044 #include <al/al.h>
00045 #include <al/alc.h>
00046 #include <al/alut.h>
00047 #endif // HAVE_OPENAL
00048
00049
00052 class CSoundEffect {
00053 public:
00054
00055 CSoundEffect (void);
00056
00057
00058 ~CSoundEffect (void);
00059
00060 public:
00061 bool bound;
00062 #ifdef HAVE_OPENAL
00063 ALuint source;
00064 ALuint buffer;
00065 #endif // HAVE_OPENAL
00066 char wavfile[256];
00067 int name;
00068 int user1, user2;
00069 };
00070
00075 class CAudioManager {
00076 public:
00077
00078 CAudioManager (void);
00079 ~CAudioManager (void);
00080
00081
00082 void Init (void);
00083 void SetListenerPosition (SPosition *p);
00084
00085 int CreateSource (void);
00086 void SetSourcePosition (int name, SPosition *p);
00087 void SetSourcePosition (int name, SVector *v);
00088 void SetSourceDirection (int name, SVector *v);
00089 void SetSourceVelocity (int name, SVector *v);
00090 void SetSourceFrequency (int name, float freqScalar);
00091 void AssignSfx (int source, int buffer);
00092
00093 int CreateSfx (PFS *pfs, const char* wavfile);
00094 int IsValidSfx (int name);
00095 int PlaySfx (int source, PFS *pfs, const char* wavfile);
00096 int PlaySfx (int source, int name);
00097 int PlaySfxDelay (int source, PFS *pfs, const char* wavfile, float delay, float *length);
00098 int PlaySfxDelay (int source, int name, float delay, float *length);
00099 void StopSfx (int name);
00100 void StopSfxByUserData (int user1, int user2);
00101 void SetSfxVolume (int name, float volume);
00102 void SetSfxPosition (int name, SPosition *p);
00103 void SetSfxPosition (int name, SVector *v);
00104 void SetSfxDirection (int name, SVector *v);
00105 void SetSfxVelocity (int name, SVector *v);
00106 void SetSfxFrequency (int name, float freqScalar);
00107 void SetSfxUserData (int name, int user1, int user2);
00108
00109 private:
00110 CSoundEffect *GetSoundEffect (int name);
00111 CSoundEffect *GetFirstSoundEffectByUserData (int user1, int user2);
00112 CSoundEffect *GetNextSoundEffectByUserData (int user1, int user2);
00113
00114
00115
00116 public:
00117 #ifdef HAVE_OPENAL
00118
00119 ALCcontext *context;
00120 ALCdevice *device;
00121 #endif // HAVE_OPENAL
00122
00123
00124 std::map<std::string,CSoundEffect*> cache;
00125
00126
00127 SPosition listenerPos;
00128
00129 private:
00130
00131 std::map<std::string,CSoundEffect*>::iterator iterUserData;
00132 };
00133
00134 #endif // AUDIOMANAGER_H_
00135