Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

audiomanagersdl.h

00001 /***************************************************************************
00002                           audiomanagersdl.h  -  description
00003         $Id: audiomanagersdl.h 3 2006-06-11 08:16:14Z neoneurone $
00004                              -------------------
00005     begin                : ven déc 26 2003
00006     copyright            : (C) 2003 by Duong-Khang NGUYEN
00007     email                : neoneurone @ users sourceforge net
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   any later version.                                                    *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #ifndef _OPENCITY_AUDIOMANAGERSDL_H_
00020 #define _OPENCITY_AUDIOMANAGERSDL_H_
00021 
00022     #include "main.h"
00023 
00024     #include "SDL_mixer.h"
00025     #include <vector>
00026 
00027     #define OC_AUDIO_FREQUENCY  44100         // CD quality
00028     #define OC_AUDIO_FORMAT     AUDIO_S16SYS  // host system signed byte order
00029     #define OC_AUDIO_CHANNELS   2             // 2 channels for stereo
00030     #define OC_AUDIO_CHUNK_SIZE 4096          // mixer's sample chunk size
00031 
00032     #define OC_AUDIO_MIX_CHANNELS 8           // total number of mix channels
00033     #define OC_AUDIO_RESERVED_CHANNELS 4      // reserved channels for sound effects
00034 
00035     #define OC_AUDIO_VOLUME_MIN 0
00036     #define OC_AUDIO_VOLUME_MAX MIX_MAX_VOLUME
00037 
00038     #define OC_MAX_FILENAME_LENGTH 255
00039 
00040 
00041 using namespace std;
00042 
00046 class AudioManager {
00047 public:
00049     enum AUDIO_CHANNEL {
00050         AUDIO_CENTER_CHANNEL = -1,
00051         AUDIO_LEFT_CHANNEL = 0,
00052         AUDIO_LEFT_HALF_CHANNEL = 1,
00053         AUDIO_RIGHT_CHANNEL = 3,
00054         AUDIO_RIGHT_HALF_CHANNEL = 2
00055     };
00056 
00057     AudioManager();
00058     ~AudioManager();
00059 
00060    //========================================================================
00063     OPENCITY_ERR_CODE OpenAudio(void);
00064     OPENCITY_ERR_CODE CloseAudio(void);
00065 
00066    //========================================================================
00069     OPENCITY_ERR_CODE
00070     LoadMusicList(
00071         const string& csrFilename,
00072         const string& csrPrefix = "" );
00073 
00074     const uint &
00075     GetNumberMusic(void) const;
00076 
00077     bool
00078     PlayingMusic(void) const;
00079 
00080     OPENCITY_ERR_CODE
00081     PlayMusic(
00082         const uint & rcuiMusicIndex,
00083         const int & rciLoops = 1 );
00084 
00085     OPENCITY_ERR_CODE
00086     PlayNextMusic(
00087         const int & rciLoops = 1 );
00088 
00089     OPENCITY_ERR_CODE
00090     PlayPreviousMusic(
00091         const int & rciLoops = 1 );
00092 
00093     void
00094     StopMusic(void) const;
00095 
00096     void
00097     ToggleRandomMusic(void);
00098 
00099     void
00100     ToggleMusic(void);
00101 
00102     void
00103     VolumeMusic( const int & rciVol ) const;
00104 
00105 
00106    //========================================================================
00111     OPENCITY_ERR_CODE
00112     LoadSoundList(
00113         const string& csrFilename,
00114         const string& csrPrefix = "" );
00115 
00116     const uint &
00117     GetNumberSound(void) const;
00118 
00119     OPENCITY_ERR_CODE
00120     PlaySound(
00121         const uint & rcuiSoundIndex,
00122         const AUDIO_CHANNEL & enumChannel = AUDIO_CENTER_CHANNEL );
00123 
00124     void
00125     ToggleSound(void);
00126 
00127     void
00128     VolumeSound( const int & rciVol ) const;
00129 
00130 
00131 
00132 private:
00133     bool boolAudioDeviceInitialized;
00134     bool boolMusicEnabled;
00135     bool boolSoundEnabled;
00136     bool boolRandomMusic;
00137 
00138     string strSoundList;
00139     vector<string> vectorSoundFilename;
00140     vector<Mix_Chunk*> vectorpSoundChunk;
00141     uint uiNumberSound;
00142 
00143     string strMusicList;
00144     vector<string> vectorMusicFilename;
00145     uint uiNumberMusic;
00146     uint uiCurrentMusic;
00147     bool boolShuffleMusic;
00148     Mix_Music* pMusicData;
00149 
00150 
00151    /*=====================================================================*/
00152    /*                        PRIVATE     METHODS                          */
00153    /*=====================================================================*/
00154     OPENCITY_ERR_CODE
00155     ParseM3UList(
00156         const string & csrFilename,
00157         vector<string> & vectorFilename,
00158         uint & uiNumberFiles );
00159 
00160 };
00161 
00162 #endif
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 

Generated on Sat Nov 11 10:21:09 2006 for OpenCity by  doxygen 1.4.2