Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

AudioEngine.h

00001 
00002 #ifndef __AUDIOENGINE_H_
00003 #define __AUDIOENGINE_H_
00004 /*
00005 Peon - Win32 Games Programming Library
00006 Copyright (C) 2002-2005 Erik Yuzwa
00007 
00008 This library is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU Library General Public
00010 License as published by the Free Software Foundation; either
00011 version 2 of the License, or (at your option) any later version.
00012 
00013 This library is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 Library General Public License for more details.
00017 
00018 You should have received a copy of the GNU Library General Public
00019 License along with this library; if not, write to the Free
00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 
00022 Erik Yuzwa
00023 peon AT wazooinc DOT com
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

Generated on Thu Dec 1 01:55:40 2005 for Peon by  doxygen 1.4.1