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 #ifndef TOLTECS_SOUND_H
23 #define TOLTECS_SOUND_H
24 
25 #include "audio/mixer.h" // for Audio::SoundHandle
26 
27 #include "toltecs/toltecs.h"
28 
29 namespace Toltecs {
30 
31 // 0x1219
32 
33 enum SoundChannelType {
34  kChannelTypeEmpty = 0,
35  kChannelTypeBackground = -1,
36  kChannelTypeSfx = -2,
37  kChannelTypeSpeech = -3
38 };
39 
40 struct SoundChannel {
41  int16 resIndex;
42  int16 type;
43  int16 volume;
44  int16 panning;
45  Audio::SoundHandle handle;
46 };
47 
48 const int kMaxChannels = 4;
49 
50 class Sound {
51 public:
52  Sound(ToltecsEngine *vm);
53  ~Sound();
54 
55  void playSpeech(int16 resIndex);
56  void playSound(int16 resIndex, int16 type, int16 volume);
57  void playSoundAtPos(int16 resIndex, int16 x, int16 y);
58  void updateSpeech();
59  void stopSpeech();
60  void stopAll();
61 
62  void saveState(Common::WriteStream *out);
63  void loadState(Common::ReadStream *in, int version);
64 
65 protected:
66  ToltecsEngine *_vm;
67 
68  SoundChannel channels[kMaxChannels];
69 
70  void clearChannel(int channel);
71  void internalPlaySound(int16 resIndex, int16 type, int16 volume, int16 panning);
72  Audio::Mixer::SoundType getScummVMSoundType(SoundChannelType type) const;
73 };
74 
75 
76 } // End of namespace Toltecs
77 
78 #endif /* TOLTECS_SOUND_H */
Definition: animation.h:28
Definition: sound.h:50
Definition: stream.h:77
Definition: mixer.h:49
SoundType
Definition: mixer.h:62
Definition: toltecs.h:94
Definition: stream.h:385
Definition: sound.h:40