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 public:
58  bool operator==(const SoundHandle &h) const { return _val == h._val; }
59 
63  bool operator!=(const SoundHandle &h) const { return _val != h._val; }
64 };
65 
71 public:
73  enum SoundType {
74  kPlainSoundType = 0,
76  kMusicSoundType = 1,
77  kSFXSoundType = 2,
78  kSpeechSoundType = 3
79  };
81  enum {
82  kMaxChannelVolume = 255,
83  kMaxMixerVolume = 256
84  };
85 
86 public:
87  Mixer() {}
88  virtual ~Mixer() {}
89 
90 
91 
104  virtual bool isReady() const = 0;
105 
109  virtual Common::Mutex &mutex() = 0;
110 
130  virtual void playStream(
131  SoundType type,
132  SoundHandle *handle,
133  AudioStream *stream,
134  int id = -1,
135  byte volume = kMaxChannelVolume,
136  int8 balance = 0,
137  DisposeAfterUse::Flag autofreeStream = DisposeAfterUse::YES,
138  bool permanent = false,
139  bool reverseStereo = false) = 0;
140 
144  virtual void stopAll() = 0;
145 
151  virtual void stopID(int id) = 0;
152 
158  virtual void stopHandle(SoundHandle handle) = 0;
159 
160 
161 
168  virtual void pauseAll(bool paused) = 0;
169 
176  virtual void pauseID(int id, bool paused) = 0;
177 
184  virtual void pauseHandle(SoundHandle handle, bool paused) = 0;
185 
186 
187 
195  virtual bool isSoundIDActive(int id) = 0;
196 
204  virtual int getSoundID(SoundHandle handle) = 0;
205 
213  virtual bool isSoundHandleActive(SoundHandle handle) = 0;
214 
215 
222  virtual void muteSoundType(SoundType type, bool mute) = 0;
223 
229  virtual bool isSoundTypeMuted(SoundType type) const = 0;
230 
237  virtual void setChannelVolume(SoundHandle handle, byte volume) = 0;
238 
246  virtual byte getChannelVolume(SoundHandle handle) = 0;
247 
255  virtual void setChannelBalance(SoundHandle handle, int8 balance) = 0;
256 
264  virtual int8 getChannelBalance(SoundHandle handle) = 0;
265 
272  virtual void setChannelFaderL(SoundHandle handle, uint8 faderL) = 0;
273 
281  virtual uint8 getChannelFaderL(SoundHandle handle) = 0;
282 
289  virtual void setChannelFaderR(SoundHandle handle, uint8 faderR) = 0;
290 
298  virtual uint8 getChannelFaderR(SoundHandle handle) = 0;
299 
306  virtual void setChannelRate(SoundHandle handle, uint32 rate) = 0;
307 
315  virtual uint32 getChannelRate(SoundHandle handle) = 0;
316 
323  virtual void resetChannelRate(SoundHandle handle) = 0;
324 
328  virtual uint32 getSoundElapsedTime(SoundHandle handle) = 0;
329 
333  virtual Timestamp getElapsedTime(SoundHandle handle) = 0;
334 
338  virtual void loopChannel(SoundHandle handle) = 0;
339 
350  virtual bool hasActiveChannelOfType(SoundType type) = 0;
351 
358  virtual void setVolumeForSoundType(SoundType type, int volume) = 0;
359 
367  virtual int getVolumeForSoundType(SoundType type) const = 0;
368 
374  virtual uint getOutputRate() const = 0;
375 
381  virtual bool getOutputStereo() const = 0;
382 
392  virtual uint getOutputBufSize() const = 0;
393 };
394 
396 } // End of namespace Audio
397 
398 #endif
bool operator!=(const SoundHandle &h) const
Definition: mixer.h:63
Definition: timestamp.h:83
Definition: noncopyable.h:39
Definition: mixer_intern.h:58
Definition: mixer.h:49
SoundType
Definition: mixer.h:73
Definition: mixer.h:70
bool operator==(const SoundHandle &h) const
Definition: mixer.h:58
Definition: mutex.h:67
Definition: audiostream.h:50
Definition: system.h:38