ScummVM API documentation
sound.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 TITANIC_SOUND_H
23 #define TITANIC_SOUND_H
24 
25 #include "titanic/support/simple_file.h"
26 #include "titanic/sound/proximity.h"
27 #include "titanic/sound/sound_manager.h"
28 #include "titanic/sound/wave_file.h"
29 #include "titanic/core/list.h"
30 #include "titanic/core/view_item.h"
31 #include "titanic/true_talk/dialogue_file.h"
32 
33 namespace Titanic {
34 
35 class CGameManager;
36 
37 class CSoundItem : public ListItem {
38 public:
39  CString _name;
40  CWaveFile *_waveFile;
41  File *_dialogueFileHandle;
42  int _speechId;
43  DisposeAfterUse::Flag _disposeAfterUse;
44  bool _active;
45 public:
46  CSoundItem() : ListItem(), _waveFile(nullptr), _dialogueFileHandle(nullptr),
47  _speechId(0), _disposeAfterUse(DisposeAfterUse::NO), _active(false) {}
48  CSoundItem(const CString &name) : ListItem(), _name(name), _waveFile(nullptr),
49  _dialogueFileHandle(nullptr), _disposeAfterUse(DisposeAfterUse::NO),
50  _speechId(0), _active(false) {}
51  CSoundItem(File *dialogueFile, int speechId) : ListItem(), _waveFile(nullptr),
52  _dialogueFileHandle(dialogueFile), _speechId(speechId), _active(false),
53  _disposeAfterUse(DisposeAfterUse::NO) {}
54  ~CSoundItem() override;
55 };
56 
57 class CSoundItemList : public List<CSoundItem> {
58 };
59 
60 class CSound {
61 private:
62  CGameManager *_gameManager;
63  CSoundItemList _sounds;
64 private:
68  void checkSounds();
69 
74  void removeOldest();
75 public:
76  QSoundManager _soundManager;
77 public:
78  CSound(CGameManager *owner, Audio::Mixer *mixer);
79  ~CSound();
80 
84  void save(SimpleFile *file) const;
85 
89  void load(SimpleFile *file);
90 
94  void preLoad();
95 
99  void postLoad() { _soundManager.postLoad(); }
100 
104  void preSave() { _soundManager.preSave(); }
105 
109  void postSave() { _soundManager.postSave(); }
110 
114  void preEnterView(CViewItem *newView, bool isNewRoom);
115 
119  bool isActive(int handle);
120 
127  void setVolume(uint handle, uint volume, uint seconds);
128 
132  void activateSound(CWaveFile *waveFile,
133  DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::NO);
134 
138  void stopChannel(int channel);
139 
146  CWaveFile *getTrueTalkSound(CDialogueFile *dialogueFile, int index);
147 
154  CWaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId);
155 
162  int playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &prox);
163 
169  CWaveFile *loadSound(const CString &name);
170 
174  int playSound(const CString &name, CProximity &prox);
175 
179  void stopSound(uint handle);
180 
184  void setCanFree(int handle);
185 
189  void updateMixer();
190 };
191 
192 } // End of namespace Titanic
193 
194 #endif /* TITANIC_SOUND_H */
virtual void postLoad()
Definition: sound_manager.h:189
Definition: sound.h:57
void load(SimpleFile *file) override
Definition: proximity.h:36
Definition: list.h:35
Definition: simple_file.h:49
virtual void postSave()
Definition: sound_manager.h:204
Definition: mixer.h:59
void postLoad()
Definition: sound.h:99
Definition: game_manager.h:48
Definition: sound_manager.h:273
Definition: list.h:71
Definition: arm.h:30
Definition: string.h:40
void save(SimpleFile *file, int indent) override
Definition: simple_file.h:41
Definition: sound.h:37
Definition: sound.h:60
Definition: dialogue_file.h:51
Definition: wave_file.h:35
void preSave()
Definition: sound.h:104
void postSave()
Definition: sound.h:109
virtual void preSave()
Definition: sound_manager.h:194
Definition: view_item.h:32