00001 /* 00002 * OpenAL sound device header 00003 * 00004 * This file is part of the "SoftPixel Engine" (Copyright (c) 2008 by Lukas Hermanns) 00005 * See "SoftPixelEngine.hpp" for license information. 00006 */ 00007 00008 #ifndef __SP_AUDIO_SOUNDDEVICE_OPENAL_H__ 00009 #define __SP_AUDIO_SOUNDDEVICE_OPENAL_H__ 00010 00011 00012 #include "Base/spStandard.hpp" 00013 00014 #ifdef SP_COMPILE_WITH_OPENAL 00015 00016 00017 #include "SoundSystem/spSoundDevice.hpp" 00018 #include "SoundSystem/OpenAL/spOpenALSound.hpp" 00019 00020 #include <AL/al.h> 00021 #include <AL/alc.h> 00022 #include <map> 00023 00024 00025 namespace sp 00026 { 00027 namespace audio 00028 { 00029 00030 00031 struct SAudioBuffer; 00032 00033 class OpenALSoundDevice : public SoundDevice 00034 { 00035 00036 public: 00037 00038 OpenALSoundDevice(); 00039 ~OpenALSoundDevice(); 00040 00041 /* Functions */ 00042 00043 io::stringc getInterface() const; 00044 00045 Sound* createSound(); 00046 SoundEffect* createSoundEffect(); 00047 00048 void updateSounds(); 00049 00050 void setListenerPosition(const dim::vector3df &Position); 00051 void setListenerVelocity(const dim::vector3df &Velocity); 00052 void setListenerOrientation(const dim::matrix4f &Orientation); 00053 00054 void setListenerSpeed(f32 Speed); 00055 00056 void setEffectSlot(SoundEffect* Sfx); 00057 00058 private: 00059 00060 friend class OpenALSound; 00061 00062 typedef std::map<std::string, ALBufferObject*> AudioBufferType; 00063 00064 /* === Macros === */ 00065 00066 static const f32 DEFAULT_SOUND_SPEED; 00067 00068 /* === Functions === */ 00069 00070 bool openALDevice(); 00071 void closeALDevice(); 00072 00073 bool loadExtensions(); 00074 00075 ALBufferObject* createSoundBuffer(const io::stringc &Filename); 00076 void dropSoundBuffer(ALBufferObject* &BufferObj); 00077 00078 /* === Members === */ 00079 00080 ALCdevice* ALDevice_; 00081 ALCcontext* ALContext_; 00082 00083 ALuint ALEffectSlot_; 00084 00085 bool HasExtensions_; 00086 00087 static AudioBufferType AudioBufferMap_; 00088 00089 }; 00090 00091 00092 } // /namespace audio 00093 00094 } // /namespace sp 00095 00096 00097 #endif 00098 00099 #endif 00100 00101 00102 00103 // ================================================================================