ScummVM API documentation
imuse.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 GRIM_IMUSE_H
23 #define GRIM_IMUSE_H
24 
25 #include "common/mutex.h"
26 
27 #include "engines/grim/imuse/imuse_track.h"
28 
29 namespace Grim {
30 
31 #define MAX_IMUSE_TRACKS 16
32 #define MAX_IMUSE_FADETRACKS 16
33 
34 struct ImuseTable;
35 class SaveGame;
36 
37 class Imuse {
38 private:
39 
40  int _callbackFps;
41 
42  Track *_track[MAX_IMUSE_TRACKS + MAX_IMUSE_FADETRACKS];
43 
44  Common::Mutex _mutex;
45  ImuseSndMgr *_sound;
46 
47  bool _pause;
48  bool _demo;
49 
50  int32 _attributes[185];
51  int32 _curMusicState;
52  int32 _curMusicSeq;
53 
54  const ImuseTable *_stateMusicTable;
55  const ImuseTable *_seqMusicTable;
56 
57  int32 makeMixerFlags(int32 flags);
58  static void timerHandler(void *refConf);
59  void callback();
60  void switchToNextRegion(Track *track);
61  int allocSlot(int priority);
62  void selectVolumeGroup(const char *soundName, int volGroupId);
63 
64  void fadeOutMusic(int fadeDelay);
65  void fadeOutMusicAndStartNew(int fadeDelay, const char *filename, int hookId, int vol, int pan);
66  Track *cloneToFadeOutTrack(Track *track, int fadeDelay);
67 
68  void playMusic(const ImuseTable *table, int atribPos, bool sequence);
69 
70  void flushTrack(Track *track);
71 
72 public:
73  Imuse(int fps, bool demo);
74  ~Imuse();
75 
76  bool startSound(const char *soundName, int volGroupId, int hookId, int volume, int pan, int priority, Track *otherTrack);
77  bool startVoice(const char *soundName, int volume = 127, int pan = 64);
78  void startMusic(const char *soundName, int hookId, int volume, int pan);
79  void startMusicWithOtherPos(const char *soundName, int hookId, int volume, int pan, Track *otherTrack);
80  void startSfx(const char *soundName, int priority = 127);
81 
82  void restoreState(SaveGame *savedState);
83  void saveState(SaveGame *savedState);
84  void resetState();
85 
86  Track *findTrack(const char *soundName);
87  void setPriority(const char *soundName, int priority);
88  void setVolume(const char *soundName, int volume);
89  int getVolume(const char *soundName);
90  void setPan(const char *soundName, int pan); /* pan: 0 .. 127 */
91  void setFadePan(const char *soundName, int destPan, int duration);
92  void setFadeVolume(const char *soundName, int destVolume, int duration);
93  void setHookId(const char *soundName, int hookId);
94  int getCountPlayedTracks(const char *soundName);
95  void stopSound(const char *soundName);
96  void stopAllSounds();
97  void pause(bool pause);
98  void setMusicState(int stateId);
99  int setMusicSequence(int seqId);
100  void refreshScripts();
101  void flushTracks();
102  bool isVoicePlaying();
103  char *getCurMusicSoundName();
104  int getCurMusicPan();
105  int getCurMusicVol();
106  bool getSoundStatus(const char *soundName);
107  int32 getPosIn16msTicks(const char *soundName);
108 };
109 
110 extern Imuse *g_imuse;
111 
112 } // end of namespace Grim
113 
114 #endif
Definition: imuse_tables.h:27
Definition: imuse_sndmgr.h:32
Definition: savegame.h:33
Definition: imuse_track.h:37
Definition: imuse.h:37
Definition: actor.h:33
Definition: mutex.h:67