00001
00002 #ifndef __AUDIOENGINE_H_
00003 #define __AUDIOENGINE_H_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "ISingleton.h"
00027
00028
00029 #define NUM_BUFFERS 30
00030
00031 #define OGG_BUFFER_SIZE (4096 * 8)
00032
00033 namespace peon
00034 {
00043 struct PEONMAIN_API AudioNode
00044 {
00046 ALuint sound_source;
00047
00048 int sound_buffer;
00049
00051 bool sound_loop;
00052
00054 ALfloat sound_position[3];
00055
00057 ALfloat sound_velocity[3];
00058
00059 public:
00063 AudioNode()
00064 {
00065 sound_source = -1;
00066 sound_buffer = -1;
00067 sound_loop = false;
00068 sound_position[0] = 0.0f;
00069 sound_position[1] = 0.0f;
00070 sound_position[2] = 0.0f;
00071
00072 sound_velocity[0] = 0.0f;
00073 sound_velocity[1] = 0.0f;
00074 sound_velocity[2] = 0.0f;
00075 }
00076
00077
00078 };
00079
00080
00087 class PEONMAIN_API AudioEngine : public ISingleton<AudioEngine>
00088 {
00089
00090 protected:
00092 ALCcontext *m_pALContext;
00093
00095 ALCdevice *m_pALDevice;
00096
00098 bool m_bEnableSound;
00099
00101 bool m_bEnableMusic;
00102
00104 ALuint m_uAudioBuffers[ NUM_BUFFERS ];
00105
00107 bool m_bAudioSupported;
00108
00109 int m_iCurrentSlot;
00110
00111
00112 public:
00116 AudioEngine();
00117
00121 ~AudioEngine();
00122
00138 static AudioEngine& getSingleton(void);
00154 static AudioEngine* getSingletonPtr(void);
00155
00156
00165 bool loadEngine( IniConfigReader* pConfig );
00166
00170 void unloadEngine();
00171
00179 Mix_Music* loadMIDI( const String& strFilename );
00180
00188 Mix_Chunk* loadWAVChunk( const String& strFilename );
00189
00190
00200 bool loadAudioNode( const String& strWAVFile, AudioNode* pNode );
00201
00207 void setAudioNode( AudioNode* pNode );
00208
00214 void playAudioNode( AudioNode* pNode );
00215
00221 void stopAudioNode( AudioNode* pNode );
00222
00226 void enableSound(){ m_bEnableSound = true; }
00227
00231 void disableSound(){ m_bEnableSound = false; }
00232
00236 void enableMusic(){ m_bEnableMusic = true; }
00237
00241 void disableMusic(){ m_bEnableMusic = false; }
00242
00243 };
00244 }
00245
00246 #endif