ScummVM API documentation
mixer.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 AUDIO_MIXER_H
23 #define AUDIO_MIXER_H
24 
25 #include "common/mutex.h"
26 #include "common/types.h"
27 #include "common/noncopyable.h"
28 
29 namespace Audio {
30 
31 class AudioStream;
32 class Channel;
33 class Timestamp;
34 
49 class SoundHandle {
50  friend class Channel;
51  friend class MixerImpl;
52  uint32 _val = 0xffffffff;
53 };
54 
60 public:
62  enum SoundType {
63  kPlainSoundType = 0,
65  kMusicSoundType = 1,
66  kSFXSoundType = 2,
67  kSpeechSoundType = 3
68  };
70  enum {
71  kMaxChannelVolume = 255,
72  kMaxMixerVolume = 256
73  };
74 
75 public:
76  Mixer() {}
77  virtual ~Mixer() {}
78 
79 
80 
93  virtual bool isReady() const = 0;
94 
98  virtual Common::Mutex &mutex() = 0;
99 
119  virtual void playStream(
120  SoundType type,
121  SoundHandle *handle,
122  AudioStream *stream,
123  int id = -1,
124  byte volume = kMaxChannelVolume,
125  int8 balance = 0,
126  DisposeAfterUse::Flag autofreeStream = DisposeAfterUse::YES,
127  bool permanent = false,
128  bool reverseStereo = false) = 0;
129 
133  virtual void stopAll() = 0;
134 
140  virtual void stopID(int id) = 0;
141 
147  virtual void stopHandle(SoundHandle handle) = 0;
148 
149 
150 
157  virtual void pauseAll(bool paused) = 0;
158 
165  virtual void pauseID(int id, bool paused) = 0;
166 
173  virtual void pauseHandle(SoundHandle handle, bool paused) = 0;
174 
175 
176 
184  virtual bool isSoundIDActive(int id) = 0;
185 
193  virtual int getSoundID(SoundHandle handle) = 0;
194 
202  virtual bool isSoundHandleActive(SoundHandle handle) = 0;
203 
204 
211  virtual void muteSoundType(SoundType type, bool mute) = 0;
212 
218  virtual bool isSoundTypeMuted(SoundType type) const = 0;
219 
226  virtual void setChannelVolume(SoundHandle handle, byte volume) = 0;
227 
235  virtual byte getChannelVolume(SoundHandle handle) = 0;
236 
244  virtual void setChannelBalance(SoundHandle handle, int8 balance) = 0;
245 
253  virtual int8 getChannelBalance(SoundHandle handle) = 0;
254 
261  virtual void setChannelRate(SoundHandle handle, uint32 rate) = 0;
262 
270  virtual uint32 getChannelRate(SoundHandle handle) = 0;
271 
278  virtual void resetChannelRate(SoundHandle handle) = 0;
279 
283  virtual uint32 getSoundElapsedTime(SoundHandle handle) = 0;
284 
288  virtual Timestamp getElapsedTime(SoundHandle handle) = 0;
289 
293  virtual void loopChannel(SoundHandle handle) = 0;
294 
305  virtual bool hasActiveChannelOfType(SoundType type) = 0;
306 
313  virtual void setVolumeForSoundType(SoundType type, int volume) = 0;
314 
322  virtual int getVolumeForSoundType(SoundType type) const = 0;
323 
329  virtual uint getOutputRate() const = 0;
330 
336  virtual bool getOutputStereo() const = 0;
337 
343  virtual uint getOutputBufSize() const = 0;
344 };
345 
347 } // End of namespace Audio
348 
349 #endif
Definition: timestamp.h:83
Definition: noncopyable.h:39
Definition: mixer_intern.h:58
Definition: mixer.h:49
SoundType
Definition: mixer.h:62
Definition: mixer.h:59
Definition: mutex.h:67
Definition: audiostream.h:50
Definition: system.h:37