ScummVM API documentation
soundrecords.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 NANCY_ACTION_SOUNDRECORDS_H
23 #define NANCY_ACTION_SOUNDRECORDS_H
24 
25 #include "engines/nancy/action/actionrecord.h"
26 
27 namespace Nancy {
28 namespace Action {
29 
30 // Sets the volume for a particular channel.
31 class SetVolume : public ActionRecord {
32 public:
33  void readData(Common::SeekableReadStream &stream) override;
34  void execute() override;
35 
36  uint16 channel = 0;
37  byte volume = 0;
38 
39 protected:
40  Common::String getRecordTypeName() const override { return "SetVolume"; }
41 };
42 
43 // Nancy 11+ AR 147. Linearly ramps a channel's volume down to 0 over
44 // the given time, then stops execution.
46 public:
47  void readData(Common::SeekableReadStream &stream) override;
48  void execute() override;
49 
50  uint16 channel = 0;
51  uint32 fadeTimeMs = 0;
52 
53 protected:
54  Common::String getRecordTypeName() const override { return "FadeSoundToSilence"; }
55 
56 private:
57  uint32 _startTime = 0;
58  uint16 _startVolume = 0;
59 };
60 
61 // Nancy 11+ AR 156. Adjusts a playing 3D sound's position and/or its
62 // min/max audible distance. A field set to kNoChange is left untouched.
63 class Update3DSound : public ActionRecord {
64 public:
65  void readData(Common::SeekableReadStream &stream) override;
66  void execute() override;
67 
68  static const int32 kNoChange = 10000;
69 
70  uint16 _channelID = 0;
71  int32 _posX = 0;
72  int32 _posY = 0;
73  int32 _posZ = 0;
74  int32 _minDistance = 0;
75  int32 _maxDistance = 0;
76 
77 protected:
78  Common::String getRecordTypeName() const override { return "Update3DSound"; }
79 };
80 
81 // Used for sound effects. From nancy3 up it includes 3D sound data, which lets
82 // the sound move in 3D space as the player rotates/changes scenes. Also supports
83 // changing the scene and/or setting a flag
84 class PlaySound : public ActionRecord {
85 public:
86  PlaySound() {}
87  ~PlaySound() { delete _soundEffect; }
88 
89  void readData(Common::SeekableReadStream &stream) override;
90  void execute() override;
91 
92  SoundDescription _sound;
93  SoundEffectDescription *_soundEffect = nullptr;
94  bool _changeSceneImmediately = false;
95  SceneChangeDescription _sceneChange;
96  FlagDescription _flag;
97 
98 protected:
99  Common::String getRecordTypeName() const override;
100 };
101 
102 // The same as PlaySound, but with the addition of captioning text,
103 // which gets displayed inside the Textbox.
104 class PlaySoundCC : public PlaySound {
105 public:
106  void readData(Common::SeekableReadStream &stream) override;
107  void execute() override;
108 
109  void readCCText(Common::SeekableReadStream &stream, Common::String &out);
110 
111  Common::String _ccText;
112 
113 protected:
114  Common::String getRecordTypeName() const override;
115 };
116 
117 // Short version of PlaySoundCC, no event flag
118 class PlaySoundTerse : public PlaySoundCC {
119 public:
120  void readData(Common::SeekableReadStream &stream) override;
121 
122 protected:
123  Common::String getRecordTypeName() const override { return "PlaySoundTerse"; }
124 };
125 
126 // Short version of PlaySoundCC, with event flag
128 public:
129  void readData(Common::SeekableReadStream &stream) override;
130 
131 protected:
132  Common::String getRecordTypeName() const override { return "PlaySoundEventFlagTerse"; }
133 };
134 
135 // Used for sounds that pan left-right depending on the scene background frame.
136 // Only used in The Vampire Diaries; later games use PlaySound's 3D sound capabilities instead
138 public:
139  void readData(Common::SeekableReadStream &stream) override;
140  void execute() override;
141 
142  SoundDescription _sound;
143 
144 protected:
145  Common::String getRecordTypeName() const override;
146 };
147 
148 // Plays a sound effect; has multiple hotspots, one per scene background frame.
149 // Used in exactly two places; one scene in tvd, and one in nancy1
151 public:
152  void readData(Common::SeekableReadStream &stream) override;
153  void execute() override;
154 
155  SoundDescription _sound; // 0x0
156  SceneChangeDescription _sceneChange; // 0x22
157  FlagDescription _flag; // 0x2A
158  Common::Array<HotspotDescription> _hotspots; // 0x31
159 
160  bool canHaveHotspot() const override { return true; }
161 
162 protected:
163  Common::String getRecordTypeName() const override { return "PlaySoundMultiHS"; }
164 };
165 
166 // Stops a sound if it's loaded and playing. Used very rarely, as sounds (usually)
167 // get auto-stopped on a scene change
168 class StopSound : public ActionRecord {
169 public:
170  void readData(Common::SeekableReadStream &stream) override;
171  void execute() override;
172 
173  uint _channelID;
174  SceneChangeWithFlag _sceneChange;
175 
176 protected:
177  Common::String getRecordTypeName() const override { return "StopSound"; }
178 };
179 
180 // Same as PlaySound, except it randomly picks between one of several
181 // provided sound files; all other settings for the sound are shared.
182 class PlayRandomSound : public PlaySound {
183 public:
184  void readData(Common::SeekableReadStream &stream) override;
185  void execute() override;
186 
187  Common::Array<Common::String> _soundNames;
188 
189  uint _selectedSound = 0;
190 
191 protected:
192  Common::String getRecordTypeName() const override { return "PlayRandomSound"; }
193 };
194 
195 // Short version of PlayRandomSound, but ALSO supports closed captioning text
197 public:
198  void readData(Common::SeekableReadStream &stream) override;
199  void execute() override;
200 
201  Common::Array<Common::String> _soundNames;
203 
204  uint _selectedSound = 0;
205 
206 protected:
207  Common::String getRecordTypeName() const override { return "PlayRandomSoundTerse"; }
208 };
209 
210 // Same as PlaySound, except it discards the filename provided in the data.
211 // Instead, it takes the current value of an item in TableData, and appends that
212 // value to the end of the base filename provided in the TABL chunk. Does not contain
213 // any CC text inside the record data; instead, that also gets copied over from TABL.
215 public:
216  void readData(Common::SeekableReadStream &stream) override;
217  void execute() override;
218 
219 protected:
220  Common::String getRecordTypeName() const override { return "TableIndexPlaySound"; }
221 
222  uint16 _tableIndex = 0;
223  int16 _lastIndexVal = -1;
224 };
225 
226 } // End of namespace Action
227 } // End of namespace Nancy
228 
229 #endif // NANCY_ACTION_NAVIGATIONRECORDS_H
Definition: str.h:59
Definition: soundrecords.h:118
Definition: soundrecords.h:31
Definition: commontypes.h:152
Definition: array.h:52
Definition: soundrecords.h:63
Definition: soundrecords.h:168
Definition: soundrecords.h:137
Definition: stream.h:745
Definition: commontypes.h:218
Definition: soundrecords.h:84
Definition: commontypes.h:172
Definition: soundrecords.h:104
Definition: actionrecord.h:97
Definition: soundrecords.h:127
Definition: soundrecords.h:214
Definition: soundrecords.h:150
Definition: soundrecords.h:196
Definition: commontypes.h:255
Definition: soundrecords.h:45
Definition: commontypes.h:167
Definition: actionmanager.h:32
Definition: soundrecords.h:182