ScummVM API documentation
riven_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 MOHAWK_RIVEN_SOUND_H
23#define MOHAWK_RIVEN_SOUND_H
24
25#include "common/array.h"
26#include "common/str.h"
27
28#include "audio/mixer.h"
29
30namespace Audio {
31class RewindableAudioStream;
32}
33
34namespace Mohawk {
35
36class MohawkEngine_Riven;
37class RivenSound;
38
42struct SLSTRecord {
43 uint16 index;
44 Common::Array<uint16> soundIds;
45 uint16 fadeFlags;
46 uint16 loop;
47 uint16 globalVolume;
48 uint16 u0;
49 uint16 suspend;
51 Common::Array<int16> balances;
53};
54
66public:
69
77 void playSound(uint16 id, uint16 volume = 255, bool playOnDraw = false);
78
80 void playCardSound(const Common::String &name, uint16 volume = 255, bool playOnDraw = false);
81
84
86 bool isEffectPlaying() const;
87
89 void stopSound();
90
92 void playSLST(const SLSTRecord &slstRecord);
93
95 void stopAllSLST(bool fade = false);
96
98 void updateSLST();
99
100private:
101 struct AmbientSound {
102 RivenSound *sound;
103 uint16 targetVolume;
104 int16 targetBalance;
105
106 AmbientSound();
107 };
108
109 struct AmbientSoundList {
110 bool fading;
111 bool suspend;
113
114 AmbientSoundList();
115 };
116
117 enum FadeFlags {
118 kFadeOutPreviousSounds = 1,
119 kFadeInNewSounds = 2
120 };
121
122 MohawkEngine_Riven *_vm;
123
124 int16 _mainAmbientSoundId;
125 AmbientSoundList _ambientSounds;
126 AmbientSoundList _previousAmbientSounds;
127 uint32 _nextFadeUpdate;
128
129 RivenSound *_effect;
130 bool _effectPlayOnDraw;
131
132 Audio::RewindableAudioStream *makeAudioStream(uint16 id);
133
134 // Ambient sound management
135 void addAmbientSounds(const SLSTRecord &record);
136 void playAmbientSounds();
137 void pauseAmbientSounds();
138 void moveAmbientSoundsToPreviousSounds();
139 void freePreviousAmbientSounds();
140
141 // Ambient sound fading
142 void setTargetVolumes(const SLSTRecord &record);
143 void applyTargetVolumes();
144 void startFadingAmbientSounds(uint16 flags);
145 void fadeAmbientSoundList(AmbientSoundList &list);
146 bool fadeVolume(AmbientSound &ambientSound);
147 bool fadeBalance(AmbientSound &ambientSound);
148 void setAmbientLooping(bool loop);
149};
150
155public:
157 ~RivenSound();
158
160 void play();
161
163 bool isPlaying() const;
164
166 void pause();
167
169 uint16 getVolume() const;
170
172 void setVolume(uint16 volume);
173
175 int16 getBalance() const;
176
178 void setBalance(int16 balance);
179
181 void setLooping(bool loop);
182
183private:
184 static byte convertVolume(uint16 volume);
185 static int8 convertBalance(int16 balance);
186
188
189 Audio::SoundHandle _handle;
190 Audio::Mixer::SoundType _mixerType;
192
193 uint16 _volume;
194 int16 _balance;
195 bool _looping;
196};
197
198} // End of namespace Mohawk
199
200#endif
SoundType
Definition: mixer.h:73
Definition: audiostream.h:109
Definition: mixer.h:49
Definition: str.h:59
Definition: riven.h:91
Definition: riven_sound.h:154
void setVolume(uint16 volume)
uint16 getVolume() const
void setLooping(bool loop)
int16 getBalance() const
void setBalance(int16 balance)
bool isPlaying() const
Definition: riven_sound.h:65
void playSound(uint16 id, uint16 volume=255, bool playOnDraw=false)
bool isEffectPlaying() const
void playCardSound(const Common::String &name, uint16 volume=255, bool playOnDraw=false)
void stopAllSLST(bool fade=false)
void playSLST(const SLSTRecord &slstRecord)
Definition: system.h:39
Definition: bitmap.h:32
Definition: riven_sound.h:42