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 #ifndef SLUDGE_SOUND_H
23 #define SLUDGE_SOUND_H
24 
25 #include "common/list.h"
26 
27 #include "audio/mixer.h"
28 
29 namespace Common {
30 class SeekableReadStream;
31 class WriteStream;
32 }
33 
34 //#include "sludge/variable.h"
35 
36 namespace Sludge {
37 
38 struct StackHandler;
39 
40 // Sound list stuff
41 struct SoundList{
42  int sound;
43  struct SoundList*next;
44  struct SoundList*prev;
45  int cacheIndex;
46  int vol;
47 };
48 
49 class SoundManager {
50 public:
51  SoundManager();
52  virtual ~SoundManager();
53 
54  // Sound list
55  void playSoundList(SoundList*s);
56  void handleSoundLists(); // to produce the same effects as end of stream call back functions
57 
58  // GENERAL...
59  void init();
60  bool initSoundStuff();
61  void killSoundStuff();
62 
63  // MUSIC...
64  bool playMOD(int, int, int);
65  void stopMOD(int);
66  void setMusicVolume(int a, int v);
67  void setDefaultMusicVolume(int v);
68 
69  // SAMPLES...
70  int cacheSound(int f);
71  bool startSound(int, bool = false);
72  void huntKillSound(int a);
73  void huntKillFreeSound(int filenum);
74  void setSoundVolume(int a, int v);
75  void setDefaultSoundVolume(int v);
76  void setSoundLoop(int a, int s, int e);
77  bool stillPlayingSound(int ch);
78  bool getSoundCacheStack(StackHandler *sH);
79  int findInSoundCache(int a);
80 
81  // Load & save
82  void loadSounds(Common::SeekableReadStream *stream);
83  void saveSounds(Common::WriteStream *stream);
84 
85  uint getSoundSource(int index);
86 
87 private:
88  const static int MAX_SAMPLES;
89  const static int MAX_MODS;
90 
91  struct SoundThing {
92  Audio::SoundHandle handle;
93  int fileLoaded, vol; //Used for wav/ogg sounds only. (sound saving/loading)
94  bool looping; //Used for wav/ogg sounds only. (sound saving/loading)
95  bool inSoundList; //Used for wav/ogg sounds only
96  };
98 
99  // there's possibility that several sound list played at the same time
100  SoundListHandles _soundListHandles;
101 
102  bool _soundOK;
103  bool _silenceIKillYou;
104  bool _isHandlingSoundList;
105 
106  SoundThing *_soundCache;
107  SoundThing *_modCache;
108 
109  int _defVol;
110  int _defSoundVol;
111  float _modLoudness;
112 
113  int _emptySoundSlot;
114 
115  void freeSound(int a);
116  bool forceRemoveSound();
117  bool deleteSoundFromList(SoundList*&s);
118  int findEmptySoundSlot();
119  int makeSoundAudioStream(int f, Audio::AudioStream *&audiostream, bool loopy);
120 };
121 
122 } // End of namespace Sludge
123 
124 #endif
Definition: stream.h:77
Definition: variable.h:60
Definition: stream.h:745
Definition: mixer.h:49
Definition: builtin.h:27
Definition: algorithm.h:29
Definition: audiostream.h:50
Definition: sound.h:41
Definition: sound.h:49