Debian Codegraph @

src/audiomanager.h

raw symbols SCIP
1 /***************************************************************************
2 audiomanager.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: audiomanager.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 // IF we have not included this file already THEN
21 #ifndef _OPENCITY_AUDIOMANAGER_H_
22 #define _OPENCITY_AUDIOMANAGER_H_ 1
23
24 #include "main.h"
25
26 #define OC_AUDIO_FREQUENCY 44100 // CD quality
27 #define OC_AUDIO_FORMAT AUDIO_S16SYS // host system signed byte order
28 #define OC_AUDIO_CHANNELS 2 // 2 channels for stereo
29 #define OC_AUDIO_CHUNK_SIZE 4096 // mixer's sample chunk size
30
31 #define OC_AUDIO_MIX_CHANNELS 8 // total number of mix channels
32 #define OC_AUDIO_RESERVED_CHANNELS 4 // reserved channels for sound effects
33
34 #define OC_AUDIO_VOLUME_MIN 0
35 #define OC_AUDIO_VOLUME_MAX MIX_MAX_VOLUME
36
37 #define OC_MAX_FILENAME_LENGTH 255
38
39
40 //========================================================================
41 /** This is a void audio manager. It is used whenever the SDL_mixer library
42 is not present
43 */
44 class AudioManager {
45 public:
46 /// This is for LR panning effects
47 enum AUDIO_CHANNEL {
48 AUDIO_CENTER_CHANNEL = -1,
49 AUDIO_LEFT_CHANNEL = 0,
50 AUDIO_LEFT_HALF_CHANNEL = 1,
51 AUDIO_RIGHT_CHANNEL = 3,
52 AUDIO_RIGHT_HALF_CHANNEL = 2
53 };
54
55 AudioManager();
56 ~AudioManager();
57
58
59 //========================================================================
60 /** WARNING: this method must be called before any use of AudioManager
61 */
62 OPENCITY_ERR_CODE OpenAudio(void);
63 OPENCITY_ERR_CODE CloseAudio(void);
64
65 //========================================================================
66 /** Set the internal filename to the given M3U music list
67 */
68 OPENCITY_ERR_CODE
69 LoadMusicList(
70 const string& csrFilename,
71 const string& csrPrefix = "" );
72
73 const uint &
74 GetNumberMusic(void) const;
75
76 bool
77 PlayingMusic(void) const;
78
79 OPENCITY_ERR_CODE
80 PlayMusic(
81 const uint & rcuiMusicIndex,
82 const int & rciLoops = 1 );
83
84 OPENCITY_ERR_CODE
85 PlayNextMusic(
86 const int & rciLoops = 1 );
87
88 OPENCITY_ERR_CODE
89 PlayPreviousMusic(
90 const int & rciLoops = 1 );
91
92 void
93 StopMusic(void) const;
94
95 void
96 ToggleRandomMusic(void);
97
98 void
99 ToggleMusic(void);
100
101 void
102 VolumeMusic( const int & rciVol ) const;
103
104
105 //========================================================================
106 /** Set the internal filename to the given M3U sound list.
107 In constrast of LoadMusicList(), it loads all the sounds specified
108 by the music list into memory for better performance.
109 */
110 OPENCITY_ERR_CODE
111 LoadSoundList(
112 const string & csrFilename,
113 const string& csrPrefix = "" );
114
115 const uint &
116 GetNumberSound(void) const;
117
118 OPENCITY_ERR_CODE
119 PlaySound(
120 const uint & rcuiSoundIndex,
121 const AUDIO_CHANNEL & enumChannel = AUDIO_CENTER_CHANNEL );
122
123 void
124 ToggleSound(void);
125
126 void
127 VolumeSound( const int & rciVol ) const;
128
129
130
131 private:
132 bool boolAudioDeviceInitialized;
133 bool boolMusicEnabled;
134 bool boolSoundEnabled;
135 uint uiNumberSound;
136 uint uiNumberMusic;
137 uint uiCurrentMusic;
138 };
139
140 #endif // _OPENCITY_AUDIOMANAGER_H_
141