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 /*
23  * Based on
24  * WebVenture (c) 2010, Sean Kasun
25  * https://github.com/mrkite/webventure, http://seancode.com/webventure/
26  *
27  * Used with explicit permission from the author
28  */
29 
30 #ifndef MACVENTURE_SOUND_H
31 #define MACVENTURE_SOUND_H
32 
33 #include "macventure/macventure.h"
34 #include "macventure/container.h"
35 
36 #include "common/file.h"
37 #include "common/hashmap.h"
38 
39 #include "audio/mixer.h"
40 
41 namespace MacVenture {
42 
43 enum SoundType {
44  kSound10 = 0x10,
45  kSound12 = 0x12,
46  kSound18 = 0x18,
47  kSound1a = 0x1a,
48  kSound44 = 0x44,
49  kSound78 = 0x78,
50  kSound7e = 0x7e
51 };
52 
53 class SoundAsset {
54 
55 public:
56  SoundAsset(Container *container, ObjID id);
57  ~SoundAsset();
58 
59  void play(Audio::Mixer *mixer, Audio::SoundHandle *soundHandle);
60  uint32 getPlayLength();
61 
62 private:
63 
64  void decode10(Common::SeekableReadStream *stream);
65  void decode12(Common::SeekableReadStream *stream);
66  void decode18(Common::SeekableReadStream *stream);
67  void decode1a(Common::SeekableReadStream *stream);
68  void decode44(Common::SeekableReadStream *stream);
69  void decode78(Common::SeekableReadStream *stream);
70  void decode7e(Common::SeekableReadStream *stream);
71 
72 private:
73 
74  Container *_container;
75  ObjID _id;
76 
77  Common::Array<byte> _data;
78  uint32 _length;
79  uint32 _frequency;
80 };
81 
82 class SoundManager {
83 public:
85  ~SoundManager();
86 
87  uint32 playSound(ObjID sound);
88 
89 private:
90  void ensureLoaded(ObjID sound);
91 
92 private:
93 
94  Container *_container;
96  Audio::SoundHandle _handle;
97  Audio::Mixer *_mixer;
98 
99 };
100 } // End of namespace MacVenture
101 
102 #endif
Definition: stream.h:745
Definition: mixer.h:49
Definition: mixer.h:59
Definition: container.h:48
Definition: hashmap.h:85
Definition: sound.h:82
Definition: macventure.h:185
Definition: container.h:38
Definition: sound.h:53