ScummVM API documentation
saud.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 #ifndef SCUMM_SMUSH_SAUD_H
22 #define SCUMM_SMUSH_SAUD_H
23 
24 #include "common/scummsys.h"
25 
26 namespace Common {
27 class SeekableReadStream;
28 }
29 
30 namespace Scumm {
31 
32 struct SaudHeader {
33  uint32 dataSize = 0;
34  uint32 sampleRate = 11025;
35  int64 scriptOffset = -1;
36  uint32 scriptSize = 0;
37 };
38 
39 // Read a SAUD container spanning the rest of the stream, leaving it at its PCM.
40 // The sample rate defaults to 11025 Hz when no rate metadata is present.
41 // allowTruncated stops at the first SDAT, accepting the available PCM prefix
42 // without reading trailing metadata. This supports Rebel SFX and auxiliary buffers.
43 // The header is only updated on success.
44 bool readSaudHeader(Common::SeekableReadStream &stream, SaudHeader &header, bool allowTruncated = false);
45 
46 enum SaudOpcode {
47  SAUD_OP_INIT = 1,
48  SAUD_OP_UPDATE_HEADER = 2,
49  SAUD_OP_SET_PARAM = 3,
50  SAUD_OP_INCR_PARAM = 4,
51  SAUD_OP_STOP = 5,
52  SAUD_OP_SET_OFFSET = 6,
53  SAUD_OP_SET_LENGTH = 7,
54  SAUD_OP_COMPARE_GT = 8,
55  SAUD_OP_COMPARE_LT = 9,
56  SAUD_OP_COMPARE_EQ = 10,
57  SAUD_OP_COMPARE_NE = 11
58 };
59 
60 enum SaudValueId {
61  SAUD_VALUEID_ALL_VOLS = 0xff,
62  SAUD_VALUEID_TRK_VOL = 0xfe,
63  SAUD_VALUEID_TRK_PAN = 0xfd
64 };
65 
66 struct SaudSpan {
67  uint32 offset = 0;
68  uint32 length = 0;
69  uint32 rate = 0;
70 };
71 
72 // STRK interpreter shared by the standalone INSANE sound players.
73 // Script storage and the 256 global variables belong to the caller.
74 class SaudScript {
75 public:
76  SaudScript();
77  void reset(const byte *data, uint32 size, uint32 defaultRate);
78  bool nextSpan(SaudSpan &span, byte *variables, int &masterVolume, byte &volume, byte &pan);
79 
80 private:
81  bool fail(const char *message);
82  bool branch(int16 displacement);
83 
84  const byte *_data;
85  uint32 _size, _position, _defaultRate;
86  uint32 _remaining, _elapsed;
87 };
88 
89 } // End of namespace Scumm
90 
91 #endif
Definition: saud.h:74
Definition: stream.h:745
Definition: saud.h:66
Definition: algorithm.h:29
Definition: saud.h:32
Definition: actor.h:30