Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 286 lines (240 sloc) 7.77 kB
218e132 @fingolfin Updated legal headers in source files, based on what Pidgin (the IM c…
fingolfin authored
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.
9809c86 @Enderboi Add boilerplate license to some files, to satisfy Debian types :)
Enderboi authored
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (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, write to the Free Software
b36677a @sev- Update FSF address. Eek. Actually that took place on May 1, 2005
sev- authored
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9809c86 @Enderboi Add boilerplate license to some files, to satisfy Debian types :)
Enderboi authored
20 *
21 */
22
3ddb6c0 @lordhoto AUDIO: Adapt include guard names to the "new" directory name.
lordhoto authored
23 #ifndef AUDIO_MIXER_H
24 #define AUDIO_MIXER_H
ac62a7c wrote new mixer class,
Ludvig Strigeus authored
25
f720d99 @fingolfin Switch Mixer::playInputStream to use DisposeAfterUse::Flag
fingolfin authored
26 #include "common/types.h"
b5a8fdc Made Mixer to subclass from Common::NonCopyable.
Alejandro Marzini authored
27 #include "common/noncopyable.h"
ea461df @fingolfin new header file for VOC specific stuff
fingolfin authored
28
2de46dc @fingolfin Moved some more stuff to namespace Audio (enough for tonight)
fingolfin authored
29 namespace Audio {
30
27307ac @fingolfin Moved the AudioCDManager as well as class AudioStream and its (standa…
fingolfin authored
31 class AudioStream;
2de46dc @fingolfin Moved some more stuff to namespace Audio (enough for tonight)
fingolfin authored
32 class Channel;
9414d7a @salty-horse JANITORIAL: Reduce header dependencies in shared code
salty-horse authored
33 class Timestamp;
2de46dc @fingolfin Moved some more stuff to namespace Audio (enough for tonight)
fingolfin authored
34
cb49cbd @fingolfin * Reimplemented Mixer::pauseAll to simply invoke pause on all channels
fingolfin authored
35 /**
36 * A SoundHandle instances corresponds to a specific sound
37 * being played via the mixer. It can be used to control that
38 * sound (pause it, stop it, etc.).
39 * @see The Mixer class
40 */
61d0e3f @fingolfin Make sure SoundHandle's are inited
fingolfin authored
41 class SoundHandle {
9edf1e6 @fingolfin cleanup
fingolfin authored
42 friend class Channel;
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
43 friend class MixerImpl;
61d0e3f @fingolfin Make sure SoundHandle's are inited
fingolfin authored
44 uint32 _val;
45 public:
46 inline SoundHandle() : _val(0xFFFFFFFF) {}
47 };
48
cb49cbd @fingolfin * Reimplemented Mixer::pauseAll to simply invoke pause on all channels
fingolfin authored
49 /**
50 * The main audio mixer handles mixing of an arbitrary number of
df4400d @fingolfin Rename input -> stream
fingolfin authored
51 * audio streams (in the form of AudioStream instances).
cb49cbd @fingolfin * Reimplemented Mixer::pauseAll to simply invoke pause on all channels
fingolfin authored
52 */
b5a8fdc Made Mixer to subclass from Common::NonCopyable.
Alejandro Marzini authored
53 class Mixer : Common::NonCopyable {
fcc46ac @fingolfin more cleanup
fingolfin authored
54 public:
67b3117 @fingolfin Added 'sound types' to the mixer - for now, only plain (for the premi…
fingolfin authored
55 enum SoundType {
0ec193b @fingolfin changing AudioDataType -> SoundType, so now the constant names match …
fingolfin authored
56 kPlainSoundType = 0,
67b3117 @fingolfin Added 'sound types' to the mixer - for now, only plain (for the premi…
fingolfin authored
57
0ec193b @fingolfin changing AudioDataType -> SoundType, so now the constant names match …
fingolfin authored
58 kMusicSoundType = 1,
59 kSFXSoundType = 2,
60 kSpeechSoundType = 3
67b3117 @fingolfin Added 'sound types' to the mixer - for now, only plain (for the premi…
fingolfin authored
61 };
6b44844 @sev- Remove trailing whitespaces.
sev- authored
62
bc882a1 @fingolfin Introduced two new constants SoundMixer::kMaxChannelVolume and SoundM…
fingolfin authored
63 enum {
64 kMaxChannelVolume = 255,
65 kMaxMixerVolume = 256
66 };
791efd8 @fingolfin lots of mixer changes: replaced _volumeTable by _globalVolume (applyi…
fingolfin authored
67
fcc46ac @fingolfin more cleanup
fingolfin authored
68 public:
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
69 Mixer() {}
70 virtual ~Mixer() {}
8786311 @fingolfin move _volume_table creation into constructor, and discard it in destr…
fingolfin authored
71
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
72
73
859a9c0 @fingolfin o Added SoundMixer::isReady()
fingolfin authored
74 /**
75 * Is the mixer ready and setup? This may not be the case on systems which
76 * don't support digital sound output. In that case, the mixer proc may
227a080 @fingolfin Patch #1663933 (Kill premix channel) with a few tiny additional tweak…
fingolfin authored
77 * never be called. That in turn can cause breakage in games which try to
6907107 @lordhoto Replace some more Adlib uses by AdLib.
lordhoto authored
78 * sync with an audio stream. In particular, the AdLib MIDI emulation...
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
79 *
80 * @return whether the mixer is ready and setup
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
81 *
82 * @todo get rid of this?
859a9c0 @fingolfin o Added SoundMixer::isReady()
fingolfin authored
83 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
84 virtual bool isReady() const = 0;
11193b0 @fingolfin cleaned up sound/mixer.h a bit; renamed some mixer methods for consis…
fingolfin authored
85
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
86
87 /**
df4400d @fingolfin Rename input -> stream
fingolfin authored
88 * Start playing the given audio stream.
cb49cbd @fingolfin * Reimplemented Mixer::pauseAll to simply invoke pause on all channels
fingolfin authored
89 *
90 * Note that the sound id assigned below is unique. At most one stream
4fbda3b @wjp Fix typo.
wjp authored
91 * with a given id can play at any given time. Trying to play a sound
cb49cbd @fingolfin * Reimplemented Mixer::pauseAll to simply invoke pause on all channels
fingolfin authored
92 * with an id that is already in use causes the new sound to be not played.
93 *
94 * @param type the type (voice/sfx/music) of the stream
95 * @param handle a SoundHandle which can be used to reference and control
96 * the stream via suitable mixer methods
df4400d @fingolfin Rename input -> stream
fingolfin authored
97 * @param stream the actual AudioStream to be played
cb49cbd @fingolfin * Reimplemented Mixer::pauseAll to simply invoke pause on all channels
fingolfin authored
98 * @param id a unique id assigned to this stream
99 * @param volume the volume with which to play the sound, ranging from 0 to 255
100 * @param balance the balance with which to play the sound, ranging from -128 to 127
101 * @param autofreeStream a flag indicating whether the stream should be
102 * freed after playback finished
103 * @param permanent a flag indicating whether a plain stopAll call should
104 * not stop this particular stream
c2dbd22 @fingolfin Added reverseStereo parameter to Mixer::playInputStream; changed Mixe…
fingolfin authored
105 * @param reverseStereo a flag indicating whether left and right channels shall be swapped
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
106 */
a1840bd @fingolfin AUDIO: Rename Mixer::playInputStream to playStream
fingolfin authored
107 virtual void playStream(
cb49cbd @fingolfin * Reimplemented Mixer::pauseAll to simply invoke pause on all channels
fingolfin authored
108 SoundType type,
109 SoundHandle *handle,
df4400d @fingolfin Rename input -> stream
fingolfin authored
110 AudioStream *stream,
b227c66 @fingolfin Remove loop start/end params from Mixer::playRaw; convert some code f…
fingolfin authored
111 int id = -1,
112 byte volume = kMaxChannelVolume,
113 int8 balance = 0,
f720d99 @fingolfin Switch Mixer::playInputStream to use DisposeAfterUse::Flag
fingolfin authored
114 DisposeAfterUse::Flag autofreeStream = DisposeAfterUse::YES,
c2dbd22 @fingolfin Added reverseStereo parameter to Mixer::playInputStream; changed Mixe…
fingolfin authored
115 bool permanent = false,
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
116 bool reverseStereo = false) = 0;
d21fc58 @fingolfin o Moved MP3 and Vorbis input streams to mp3.* resp. vorbis.*
fingolfin authored
117
caa3db4 @lordhoto - Initial implementation of looping of SeekableAudioStreams in Mixer.
lordhoto authored
118 /**
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
119 * Stop all currently playing sounds.
120 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
121 virtual void stopAll() = 0;
ac62a7c wrote new mixer class,
Ludvig Strigeus authored
122
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
123 /**
124 * Stop playing the sound with given ID.
125 *
126 * @param id the ID of the sound to affect
127 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
128 virtual void stopID(int id) = 0;
80e3c23 @fingolfin cleanup; add stopID method to stop a currently playing sound via its ID
fingolfin authored
129
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
130 /**
131 * Stop playing the sound corresponding to the given handle.
132 *
133 * @param handle the sound to affect
134 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
135 virtual void stopHandle(SoundHandle handle) = 0;
33e6989 @fingolfin removed whitespaces at line ends; added stopHandle
fingolfin authored
136
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
137
138
139 /**
258901b @peres Merged common/stdafx.h into common/scummsys.h. All referencing files …
peres authored
140 * Pause/unpause all sounds, including all regular and permanent
227a080 @fingolfin Patch #1663933 (Kill premix channel) with a few tiny additional tweak…
fingolfin authored
141 * channels
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
142 *
cb49cbd @fingolfin * Reimplemented Mixer::pauseAll to simply invoke pause on all channels
fingolfin authored
143 * @param paused true to pause everything, false to unpause
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
144 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
145 virtual void pauseAll(bool paused) = 0;
11193b0 @fingolfin cleaned up sound/mixer.h a bit; renamed some mixer methods for consis…
fingolfin authored
146
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
147 /**
148 * Pause/unpause the sound with the given ID.
149 *
150 * @param id the ID of the sound to affect
151 * @param paused true to pause the sound, false to unpause it
152 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
153 virtual void pauseID(int id, bool paused) = 0;
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
154
155 /**
156 * Pause/unpause the sound corresponding to the given handle.
157 *
158 * @param handle the sound to affect
159 * @param paused true to pause the sound, false to unpause it
160 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
161 virtual void pauseHandle(SoundHandle handle, bool paused) = 0;
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
162
163
164
165 /**
166 * Check if a sound with the given ID is active.
167 *
168 * @param id the ID of the sound to query
169 * @return true if the sound is active
170 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
171 virtual bool isSoundIDActive(int id) = 0;
e22230e Actually check if a sound is active, if the sound is outside music en…
Travis Howell authored
172
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
173 /**
f230fe6 Add 8 sound channel support for HE games
Travis Howell authored
174 * Get the sound ID of handle sound
175 *
176 * @param handle sound to query
177 * @return sound ID if active
178 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
179 virtual int getSoundID(SoundHandle handle) = 0;
f230fe6 Add 8 sound channel support for HE games
Travis Howell authored
180
181 /**
cb49cbd @fingolfin * Reimplemented Mixer::pauseAll to simply invoke pause on all channels
fingolfin authored
182 * Check if a sound with the given handle is active.
7cd2cb2 @fingolfin PlayingSoundHandle -> SoundHandle; also, turned the handle activity c…
fingolfin authored
183 *
f230fe6 Add 8 sound channel support for HE games
Travis Howell authored
184 * @param handle sound to query
7cd2cb2 @fingolfin PlayingSoundHandle -> SoundHandle; also, turned the handle activity c…
fingolfin authored
185 * @return true if the sound is active
186 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
187 virtual bool isSoundHandleActive(SoundHandle handle) = 0;
7cd2cb2 @fingolfin PlayingSoundHandle -> SoundHandle; also, turned the handle activity c…
fingolfin authored
188
f486997 Added per-channel pausing. Maybe I should have named the pauseChannel()
Torbjörn Andersson authored
189
12a3120 @lordhoto AUDIO: Add per sound type mute flag setting to Mixer(Impl).
lordhoto authored
190 /**
191 * Set the mute state for a given sound type.
192 *
193 * @param type the sound type
6b0ccbb @lordhoto AUDIO: Renamed mute related functions in Mixer.
lordhoto authored
194 * @param mute Whether to mute (= true) or not (= false).
12a3120 @lordhoto AUDIO: Add per sound type mute flag setting to Mixer(Impl).
lordhoto authored
195 */
6b0ccbb @lordhoto AUDIO: Renamed mute related functions in Mixer.
lordhoto authored
196 virtual void muteSoundType(SoundType type, bool mute) = 0;
12a3120 @lordhoto AUDIO: Add per sound type mute flag setting to Mixer(Impl).
lordhoto authored
197
198 /**
199 * Query the mute state for a given sound type.
200 *
201 * @param type the sound type
202 */
6b0ccbb @lordhoto AUDIO: Renamed mute related functions in Mixer.
lordhoto authored
203 virtual bool isSoundTypeMuted(SoundType type) const = 0;
f486997 Added per-channel pausing. Maybe I should have named the pauseChannel()
Torbjörn Andersson authored
204
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
205 /**
206 * Set the channel volume for the given handle.
207 *
208 * @param handle the sound to affect
33fd755 @fingolfin use kMaxChannelVolume instead of hardcoding 255
fingolfin authored
209 * @param volume the new channel volume (0 - kMaxChannelVolume)
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
210 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
211 virtual void setChannelVolume(SoundHandle handle, byte volume) = 0;
2533b23 @aquadran added mixer features: volume and pan control per channel
aquadran authored
212
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
213 /**
eb13803 @sev- AUDIO: Add complementary functions for getting channel volume and bal…
sev- authored
214 * Get the channel volume for the given handle.
215 *
216 * @param handle the sound to affect
217 * @return channel volume
218 */
219 virtual byte getChannelVolume(SoundHandle handle) = 0;
220
221 /**
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
222 * Set the channel balance for the given handle.
223 *
224 * @param handle the sound to affect
225 * @param balance the new channel balance:
226 * (-127 ... 0 ... 127) corresponds to (left ... center ... right)
227 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
228 virtual void setChannelBalance(SoundHandle handle, int8 balance) = 0;
2533b23 @aquadran added mixer features: volume and pan control per channel
aquadran authored
229
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
230 /**
eb13803 @sev- AUDIO: Add complementary functions for getting channel volume and bal…
sev- authored
231 * Get the channel balance for the given handle.
232 *
233 * @param handle the sound to affect
234 * @return channel balance
235 */
236 virtual int8 getChannelBalance(SoundHandle handle) = 0;
237
238 /**
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
239 * Get approximation of for how long the channel has been playing.
240 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
241 virtual uint32 getSoundElapsedTime(SoundHandle handle) = 0;
9003dbb With no comments from fingolfin, and a go-ahead from ender, I've comm…
Torbjörn Andersson authored
242
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
243 /**
a44c6e4 @fingolfin Add Mixer::getElapsedTime() method returning a Timestamp, thus offeri…
fingolfin authored
244 * Get approximation of for how long the channel has been playing.
245 */
246 virtual Timestamp getElapsedTime(SoundHandle handle) = 0;
247
248 /**
67b3117 @fingolfin Added 'sound types' to the mixer - for now, only plain (for the premi…
fingolfin authored
249 * Check whether any channel of the given sound type is active.
250 * For example, this can be used to check whether any SFX sound
0ec193b @fingolfin changing AudioDataType -> SoundType, so now the constant names match …
fingolfin authored
251 * is currently playing, by checking for type kSFXSoundType.
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
252 *
67b3117 @fingolfin Added 'sound types' to the mixer - for now, only plain (for the premi…
fingolfin authored
253 * @param type the sound type to look for
254 * @return true if any channels of the specified type are active.
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
255 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
256 virtual bool hasActiveChannelOfType(SoundType type) = 0;
1f99fbe @aquadran cleanup whitespaces
aquadran authored
257
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
258 /**
67b3117 @fingolfin Added 'sound types' to the mixer - for now, only plain (for the premi…
fingolfin authored
259 * Set the volume for the given sound type.
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
260 *
d00117e @fingolfin Fixed some doxygen warnings
fingolfin authored
261 * @param type the sound type
33fd755 @fingolfin use kMaxChannelVolume instead of hardcoding 255
fingolfin authored
262 * @param volume the new global volume, 0 - kMaxMixerVolume
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
263 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
264 virtual void setVolumeForSoundType(SoundType type, int volume) = 0;
1f99fbe @aquadran cleanup whitespaces
aquadran authored
265
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
266 /**
267 * Query the global volume.
268 *
d00117e @fingolfin Fixed some doxygen warnings
fingolfin authored
269 * @param type the sound type
33fd755 @fingolfin use kMaxChannelVolume instead of hardcoding 255
fingolfin authored
270 * @return the global music volume, 0 - kMaxMixerVolume
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
271 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
272 virtual int getVolumeForSoundType(SoundType type) const = 0;
1f99fbe @aquadran cleanup whitespaces
aquadran authored
273
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
274 /**
c97ee14 @fingolfin Remove last traces of OSystem::getOutputSampleRate()
fingolfin authored
275 * Query the system's audio output sample rate.
ba74a8e @fingolfin Added some more mixer doxygen docs; cleaned up Mixer API a bit, remov…
fingolfin authored
276 *
277 * @return the output sample rate in Hz
278 */
c45d632 @fingolfin Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
fingolfin authored
279 virtual uint getOutputRate() const = 0;
ac62a7c wrote new mixer class,
Ludvig Strigeus authored
280 };
281
1a61534 @fingolfin Moved class SoundMixer to Audio::Mixer (didn't call the namespace 'So…
fingolfin authored
282
283 } // End of namespace Audio
284
89cf95c @fingolfin pedantic #define rename :-)
fingolfin authored
285 #endif
Something went wrong with that request. Please try again.