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

audiomanager.h

00001 /***************************************************************************
00002                           audiomanager.h  -  description
00003         $Id: audiomanager.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 // IF we don't use SDL_mixer THEN
00020 #ifndef AUDIO_SDL
00021 
00022 // IF we have not included this file already THEN
00023 #ifndef _OPENCITY_AUDIOMANAGER_H_
00024 
00025 #define _OPENCITY_AUDIOMANAGER_H_ 1
00026 
00027     #include "main.h"
00028 
00029     #define OC_AUDIO_FREQUENCY  44100         // CD quality
00030     #define OC_AUDIO_FORMAT     AUDIO_S16SYS  // host system signed byte order
00031     #define OC_AUDIO_CHANNELS   2             // 2 channels for stereo
00032     #define OC_AUDIO_CHUNK_SIZE 4096          // mixer's sample chunk size
00033 
00034     #define OC_AUDIO_MIX_CHANNELS 8           // total number of mix channels
00035     #define OC_AUDIO_RESERVED_CHANNELS 4      // reserved channels for sound effects
00036 
00037     #define OC_AUDIO_VOLUME_MIN 0
00038     #define OC_AUDIO_VOLUME_MAX MIX_MAX_VOLUME
00039 
00040     #define OC_MAX_FILENAME_LENGTH 255
00041 
00042 
00043 using namespace std;
00044 
00045 //========================================================================
00049 class AudioManager {
00050 public:
00052     enum AUDIO_CHANNEL {
00053         AUDIO_CENTER_CHANNEL = -1,
00054         AUDIO_LEFT_CHANNEL = 0,
00055         AUDIO_LEFT_HALF_CHANNEL = 1,
00056         AUDIO_RIGHT_CHANNEL = 3,
00057         AUDIO_RIGHT_HALF_CHANNEL = 2
00058     };
00059 
00060     AudioManager();
00061     ~AudioManager();
00062 
00063 
00064 //========================================================================
00067     OPENCITY_ERR_CODE OpenAudio(void);
00068     OPENCITY_ERR_CODE CloseAudio(void);
00069 
00070 //========================================================================
00073     OPENCITY_ERR_CODE
00074     LoadMusicList(
00075         const string& csrFilename,
00076         const string& csrPrefix = "" );
00077 
00078     const uint &
00079     GetNumberMusic(void) const;
00080 
00081     bool
00082     PlayingMusic(void) const;
00083 
00084     OPENCITY_ERR_CODE
00085     PlayMusic(
00086         const uint & rcuiMusicIndex,
00087         const int & rciLoops = 1 );
00088 
00089     OPENCITY_ERR_CODE
00090     PlayNextMusic(
00091         const int & rciLoops = 1 );
00092 
00093     OPENCITY_ERR_CODE
00094     PlayPreviousMusic(
00095         const int & rciLoops = 1 );
00096 
00097     void
00098     StopMusic(void) const;
00099 
00100     void
00101     ToggleRandomMusic(void);
00102 
00103     void
00104     ToggleMusic(void);
00105 
00106     void
00107     VolumeMusic( const int & rciVol ) const;
00108 
00109 
00110 //========================================================================
00115     OPENCITY_ERR_CODE
00116     LoadSoundList(
00117         const string & csrFilename,
00118         const string& csrPrefix = "" );
00119 
00120     const uint &
00121     GetNumberSound(void) const;
00122 
00123     OPENCITY_ERR_CODE
00124     PlaySound(
00125         const uint & rcuiSoundIndex,
00126         const AUDIO_CHANNEL & enumChannel = AUDIO_CENTER_CHANNEL );
00127 
00128     void
00129     ToggleSound(void);
00130 
00131     void
00132     VolumeSound( const int & rciVol ) const;
00133 
00134 
00135 
00136 private:
00137     bool boolAudioDeviceInitialized;
00138     bool boolMusicEnabled;
00139     bool boolSoundEnabled;
00140     uint uiNumberSound;
00141     uint uiNumberMusic;
00142     uint uiCurrentMusic;
00143 };
00144 
00145 // ELSE, we have included this file already
00146 #else
00147 #endif
00148 
00149 // ELSE, we use SDL_mixer
00150 #else
00151 #include "audiomanagersdl.h"
00152 #endif
00153 
00154 
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 

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