ScummVM API documentation
vabsound.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 DRAGONS_VABSOUND_H
23 #define DRAGONS_VABSOUND_H
24 
25 #include "common/scummsys.h"
26 
27 namespace Common {
28  class SeekableReadStream;
29 }
30 
31 namespace Audio {
32  class AudioStream;
33 }
34 
35 namespace Dragons {
36 class DragonsEngine;
37 
38 #define DRAGONS_VAB_NUM_PROG_ATTRS 128
39 
40 struct VabHeader {
41  char magic[4];
42 
43  uint32 version;
44  uint32 vabId;
45  uint32 waveformSize;
46 
47  uint16 reserved0;
48  uint16 numPrograms;
49  uint16 numTones;
50  uint16 numVAG;
51 
52  uint8 masterVolume;
53  uint8 masterPan;
54  uint8 bankAttr1;
55  uint8 bankAttr2;
56 
57  uint32 reserved1;
58 };
59 
61  uint8 tones;
62  uint8 mvol;
63  uint8 prior;
64  uint8 mode;
65  uint8 mpan;
66  uint8 reserved0;
67  uint16 attr;
68  uint32 reserved1;
69  uint32 reserved2;
70 };
71 
72 struct VabToneAttr {
73  uint8 prior;
74  uint8 mode;
75  uint8 vol;
76  uint8 pan;
77  uint8 center;
78  uint8 shift;
79  uint8 min;
80  uint8 max;
81  uint8 vibW;
82  uint8 vibT;
83  uint8 porW;
84  uint8 porT;
85  uint8 pbmin;
86  uint8 pbmax;
87  uint8 reserved1;
88  uint8 reserved2;
89  uint16 adsr1;
90  uint16 adsr2;
91  int16 prog;
92  int16 vag;
93  int16 reserved[4];
94 };
95 
96 class VabSound {
97 public:
102  VabSound(Common::SeekableReadStream* msfData, const DragonsEngine *_vm);
103 
111 
112  ~VabSound();
113 
114  bool hasSound(uint16 program, uint16 key);
115  Audio::AudioStream *getAudioStream(uint16 program, uint16 key);
116 
117 private:
118  byte *_vbData;
119 
120  VabHeader _header;
121  VabProgramAttr _programAttrs[DRAGONS_VAB_NUM_PROG_ATTRS];
122  VabToneAttr *_toneAttrs;
123 
124  uint32 _vagSizes[0x100];
125  uint32 _vagOffsets[0x100];
126 
127  void loadHeader(Common::SeekableReadStream *vhData);
128  void loadProgramAttributes(Common::SeekableReadStream *vhData);
129  void loadToneAttributes(Common::SeekableReadStream *vhData);
130 
131  int16 getVagID(uint16 program, uint16 key);
132  int16 getBaseToneKey(uint16 program, uint16 key);
133 
134  int getAdjustedSampleRate(int16 desiredKey, int16 baseToneKey);
135 };
136 
137 } // End of namespace Dragons
138 
139 #endif //DRAGONS_VABSOUND_H
Definition: vabsound.h:60
Definition: vabsound.h:96
Definition: stream.h:745
Definition: algorithm.h:29
Definition: audiostream.h:50
Definition: actor.h:26
Definition: vabsound.h:72
Definition: vabsound.h:40
Definition: dragons.h:167
Definition: system.h:38