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 // Sound class
23 
24 #ifndef SAGA_SOUND_H
25 #define SAGA_SOUND_H
26 
27 #include "common/file.h"
28 #include "audio/mixer.h"
29 #include "audio/timestamp.h"
30 
31 namespace Audio {
32 class RewindableAudioStream;
33 }
34 
35 namespace Saga {
36 
37 #define SOUND_HANDLES 10
38 
39 enum SOUND_FLAGS {
40  SOUND_LOOP = 1
41 };
42 
43 struct SoundBuffer {
45  Audio::Timestamp streamLength;
46 };
47 
48 enum sndHandleType {
49  kFreeHandle,
50  kEffectHandle,
51  kVoiceHandle
52 };
53 
54 struct SndHandle {
55  Audio::SoundHandle handle;
56  sndHandleType type;
57  int resId;
58 };
59 
60 class Sound {
61 public:
62 
63  Sound(SagaEngine *vm, Audio::Mixer *mixer);
64  ~Sound();
65 
66  void playSound(SoundBuffer &buffer, int volume, bool loop, int resId);
67  void pauseSound();
68  void resumeSound();
69  void stopSound();
70 
71  void playVoice(SoundBuffer &buffer);
72  void pauseVoice();
73  void resumeVoice();
74  void stopVoice();
75 
76  void stopAll();
77 
78  void setVolume();
79 
80  private:
81 
82  void playSoundBuffer(Audio::SoundHandle *handle, const SoundBuffer &buffer, int volume,
83  sndHandleType handleType, bool loop);
84 
85  SndHandle *getHandle();
86 
87  SagaEngine *_vm;
88  Audio::Mixer *_mixer;
89 
90  SndHandle _handles[SOUND_HANDLES];
91 };
92 
93 } // End of namespace Saga
94 
95 #endif
Definition: saga.h:497
Definition: timestamp.h:83
Definition: sound.h:60
Definition: sound.h:54
Definition: mixer.h:49
Definition: mixer.h:59
Definition: actor.h:34
Definition: audiostream.h:109
Definition: sound.h:43
Definition: system.h:38