Debian Codegraph @

src/audiomanagersdl.h

raw symbols SCIP
1 /***************************************************************************
2 audiomanagersdl.h - description
3 -------------------
4 begin : december 26th, 2003
5 copyright : (C) 2003-2008 by Duong Khang NGUYEN
6 email : neoneurone @ gmail com
7
8 $Id: audiomanagersdl.h 375 2008-10-28 14:47:15Z neoneurone $
9 ***************************************************************************/
10
11 /***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * any later version. *
17 * *
18 ***************************************************************************/
19
20 #ifndef _OPENCITY_AUDIOMANAGERSDL_H_
21 #define _OPENCITY_AUDIOMANAGERSDL_H_ 1
22
23 #include "main.h"
24
25 #include "SDL_mixer.h"
26 #include <vector>
27
28 #define OC_AUDIO_FREQUENCY 44100 // CD quality
29 #define OC_AUDIO_FORMAT AUDIO_S16SYS // host system signed byte order
30 #define OC_AUDIO_CHANNELS 2 // 2 channels for stereo
31 #define OC_AUDIO_CHUNK_SIZE 4096 // mixer's sample chunk size
32
33 #define OC_AUDIO_MIX_CHANNELS 8 // total number of mix channels
34 #define OC_AUDIO_RESERVED_CHANNELS 4 // reserved channels for sound effects
35
36 #define OC_AUDIO_VOLUME_MIN 0
37 #define OC_AUDIO_VOLUME_MAX MIX_MAX_VOLUME
38
39 #define OC_MAX_FILENAME_LENGTH 255
40
41
42 //========================================================================
43 /** Handles audio aspect of OpenCity. Thanks to SDL_Mixer, it can play
44 most popular types of sound and music files.
45 */
46 class AudioManager {
47 public:
48 /// This is for LR panning effects
49 enum AUDIO_CHANNEL {
50 AUDIO_CENTER_CHANNEL = -1,
51 AUDIO_LEFT_CHANNEL = 0,
52 AUDIO_LEFT_HALF_CHANNEL = 1,
53 AUDIO_RIGHT_CHANNEL = 3,
54 AUDIO_RIGHT_HALF_CHANNEL = 2
55 };
56
57 AudioManager();
58 ~AudioManager();
59
60 //========================================================================
61 /** WARNING: this method must be called before any use of AudioManager
62 */
63 OPENCITY_ERR_CODE OpenAudio(void);
64 OPENCITY_ERR_CODE CloseAudio(void);
65
66 //========================================================================
67 /** Set the internal filename to the given M3U music list
68 */
69 OPENCITY_ERR_CODE
70 LoadMusicList(
71 const string& csrFilename,
72 const string& csrPrefix = "" );
73
74 const uint &
75 GetNumberMusic(void) const;
76
77 bool
78 PlayingMusic(void) const;
79
80 OPENCITY_ERR_CODE
81 PlayMusic(
82 const uint & rcuiMusicIndex,
83 const int & rciLoops = 1 );
84
85 OPENCITY_ERR_CODE
86 PlayNextMusic(
87 const int & rciLoops = 1 );
88
89 OPENCITY_ERR_CODE
90 PlayPreviousMusic(
91 const int & rciLoops = 1 );
92
93 void
94 StopMusic(void) const;
95
96 void
97 ToggleRandomMusic(void);
98
99 void
100 ToggleMusic(void);
101
102 void
103 VolumeMusic( const int & rciVol ) const;
104
105
106 //========================================================================
107 /** Set the internal filename to the given M3U sound list.
108 In constrast of LoadMusicList(), it loads all the sounds specified
109 by the music list into memory for better performance.
110 */
111 OPENCITY_ERR_CODE
112 LoadSoundList(
113 const string& csrFilename,
114 const string& csrPrefix = "" );
115
116 const uint &
117 GetNumberSound(void) const;
118
119 OPENCITY_ERR_CODE
120 PlaySound(
121 const uint & rcuiSoundIndex,
122 const AUDIO_CHANNEL & enumChannel = AUDIO_CENTER_CHANNEL );
123
124 void
125 ToggleSound(void);
126
127 void
128 VolumeSound( const int & rciVol ) const;
129
130
131
132 private:
133 bool boolAudioDeviceInitialized;
134 bool boolMusicEnabled;
135 bool boolSoundEnabled;
136 bool boolRandomMusic;
137
138 string strSoundList;
139 std::vector<string> _vSoundFilename;
140 std::vector<Mix_Chunk*> _vpSoundChunk;
141 uint uiNumberSound;
142
143 string strMusicList;
144 std::vector<string> vectorMusicFilename;
145 uint uiNumberMusic;
146 uint uiCurrentMusic;
147 bool boolShuffleMusic;
148 Mix_Music* pMusicData;
149
150
151 /*=====================================================================*/
152 /* PRIVATE METHODS */
153 /*=====================================================================*/
154 OPENCITY_ERR_CODE
155 ParseM3UList(
156 const string & csrFilename,
157 std::vector<string> & vectorFilename,
158 uint & uiNumberFiles );
159
160 };
161
162 #endif
163
164
165
166
167
168
169
170
171
172
173
174
175