ScummVM API documentation
sounddesc.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  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_SOUND_SOUNDDESC_H
29 #define GOB_SOUND_SOUNDDESC_H
30 
31 #include "common/endian.h"
32 
33 namespace Gob {
34 
35 class Resource;
36 
37 enum SoundType {
38  SOUND_SND,
39  SOUND_WAV,
40  SOUND_ADL
41 };
42 
43 class SoundDesc {
44 public:
45  int16 _repCount;
46  int16 _frequency;
47  int16 _flag;
48  int16 _id;
49  byte _mixerFlags;
50 
51  SoundDesc();
52  ~SoundDesc();
53 
54  void swap(SoundDesc &desc);
55 
56  byte *getData() { return _dataPtr; }
57 
58  uint32 size() const { return _size; }
59  bool empty() const { return !_dataPtr; }
60  SoundType getType() const { return _type; }
61 
62  bool isId(int16 id) const { return _dataPtr && (_id == id); }
63 
64  void set(SoundType type, byte *data, uint32 dSize);
65  bool load(SoundType type, byte *data, uint32 dSize);
66  bool load(SoundType type, Resource *resource);
67 
68  void free();
69  void convToSigned();
70 
71  // Which fade out length to use when the fade starts half-way through?
72  int16 calcFadeOutLength(int16 frequency);
73  uint32 calcLength(int16 repCount, int16 frequency, bool fade);
74 
75 private:
76  Resource *_resource;
77  byte *_data;
78  byte *_dataPtr;
79  uint32 _size;
80 
81  SoundType _type;
82 
83  bool loadSND(byte *data, uint32 dSize);
84  bool loadWAV(byte *data, uint32 dSize);
85  bool loadADL(byte *data, uint32 dSize);
86 };
87 
88 } // End of namespace Gob
89 
90 #endif // GOB_SOUND_SOUNDDESC_H
Definition: anifile.h:40
Definition: sounddesc.h:43
Definition: resources.h:42