ScummVM API documentation
soundManager.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 SOUND_MANAGER_H
23 #define SOUND_MANAGER_H
24 
25 #include "audio/mixer.h"
26 #include "common/hashmap.h"
27 #include "common/list.h"
28 #include "common/scummsys.h"
29 #include "common/str.h"
30 
31 namespace Common {
32 class SeekableReadStream;
33 }
34 namespace Audio {
35 class Mixer;
36 }
37 
38 namespace AGDS {
39 class AGDSEngine;
40 
41 struct Sound {
42  int id;
43  Common::String process;
44  Common::String resource;
45  Common::String filename;
46  Common::String phaseVar;
47  Audio::SoundHandle handle;
48  int volume;
49  int pan;
50  int group;
51  bool paused;
52  Sound(int id_, const Common::String &process_, const Common::String &res, const Common::String &filename_, const Common::String &var, int volume_, int pan_, int group_ = 0) : id(id_), process(process_), resource(res), filename(filename_), phaseVar(var), handle(), volume(volume_), pan(pan_), group(group_), paused(false) {
53  }
54 
55  int leftVolume() const {
56  return pan < 0 ? volume : volume * (100 - pan) / 100;
57  }
58 
59  int rightVolume() const {
60  return pan < 0 ? volume * (100 + pan) / 100 : volume;
61  }
62 };
63 
64 class SoundManager {
66  int _nextId;
67  AGDSEngine *_engine;
68  Audio::Mixer *_mixer;
69  SoundList _sounds;
70 
71 public:
72  SoundManager(AGDSEngine *engine, Audio::Mixer *mixer) : _nextId(1), _engine(engine), _mixer(mixer) {}
73  void tick();
74  int play(Common::String process, const Common::String &resource, const Common::String &filename, const Common::String &phaseVar, bool startPlaying, int volume, int pan, int id = -1, bool ambient = false);
75  bool playing(int id) const;
76  void stopAllFrom(const Common::String &process);
77  void stopAll();
78  const Sound *find(int id) const;
79  Sound *findSampleByPhaseVar(const Common::String &phaseVar);
80 };
81 
82 } // End of namespace AGDS
83 
84 #endif /* AGDS_SOUND_MANAGER_H */
Definition: str.h:59
In find(In first, In last, const T &v)
Definition: algorithm.h:225
Definition: mixer.h:49
Definition: agds.h:58
Definition: mixer.h:70
Definition: algorithm.h:29
Definition: soundManager.h:64
Definition: agds.h:81
Definition: soundManager.h:41
Definition: system.h:38