ScummVM API documentation
sound_manager.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef MADS_CORE_SOUND_MANAGER_H
23 #define MADS_CORE_SOUND_MANAGER_H
24 
25 #include "common/array.h"
26 #include "common/file.h"
27 #include "common/mutex.h"
28 #include "common/queue.h"
29 
30 namespace Audio {
31 class Mixer;
32 }
33 
34 namespace OPL {
35 class OPL;
36 }
37 
38 namespace MADS {
39 
40 class SoundDriver {
41 protected:
42  Audio::Mixer *_mixer;
43  OPL::OPL *_opl;
44 
45 public:
46  SoundDriver(Audio::Mixer *mixer, OPL::OPL *opl) : _mixer(mixer), _opl(opl) {}
47  virtual ~SoundDriver() {
48  }
49 
56  virtual int command(int commandId, int param) = 0;
57 
61  virtual int stop() = 0;
62 
66  virtual int poll() {
67  return 0;
68  }
69 
73  virtual void noise() = 0;
74 
78  virtual void setVolume(int volume) = 0;
79 };
80 
81 class SoundManager {
82 protected:
83  Audio::Mixer *_mixer;
84  bool &_soundFlag;
85  OPL::OPL *_opl = nullptr;
86  SoundDriver *_driver = nullptr;
87  bool _pollSoundEnabled = false;
88  bool _soundPollFlag = false;
89  bool _newSoundsPaused = false;
90  Common::Queue<int> _queuedCommands;
91  int _masterVolume = 255;
92 
93 protected:
98  virtual void loadDriver(int sectionNum) = 0;
99 
100 public:
101  SoundManager(Audio::Mixer *mixer, bool &soundFlag);
102  virtual ~SoundManager();
103 
104  virtual void validate() = 0;
105 
106  bool _preferRoland;
107 
111  void init(int sectionNumber);
112 
116  void closeDriver();
117 
121  void removeDriver();
122 
127  void setEnabled(bool flag);
128 
132  void pauseNewCommands();
133 
137  void startQueuedCommands();
138 
142  void setVolume(int volume);
143 
145 
150  int command(int commandId, int param = 0);
151 
155  void stop();
156 
161  void noise();
162 
164 };
165 
166 
167 } // namespace MADS
168 
169 #endif
Definition: mixer.h:70
Definition: sound_manager.h:81
virtual int poll()
Definition: sound_manager.h:66
Definition: sound_manager.h:40
Definition: fmopl.h:35
Definition: sound_manager.h:38
Definition: system.h:38
Definition: fmopl.h:116