ScummVM API documentation
MusicHandler.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 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_MUSICHANDLER_H
29 #define HPL_MUSICHANDLER_H
30 
31 #include "common/list.h"
32 #include "hpl1/engine/system/SystemTypes.h"
33 
34 namespace hpl {
35 
36 class iLowLevelSound;
37 class iSoundChannel;
38 
42 
43 class cMusicLock {
44 public:
45  cMusicLock() : msFileName(""), mfVolume(0) {}
46 
47  tString msFileName;
48  float mfVolume;
49  bool mbLoop;
50 };
51 
55 
56 class cMusicEntry {
57 public:
58  cMusicEntry() : msFileName(""), mpStream(NULL), mfMaxVolume(1),
59  mfVolume(0), mfVolumeAdd(0.01f) {}
60 
61  tString msFileName;
62  iSoundChannel *mpStream;
63  float mfMaxVolume;
64  float mfVolume;
65  float mfVolumeAdd;
66  bool mbLoop;
67 };
68 
71 
75 
76 class cResources;
77 
79 public:
80  cMusicHandler(iLowLevelSound *apLowLevelSound, cResources *apResources);
81  ~cMusicHandler();
82 
91  bool Play(const tString &asFileName, float afVolume, float afFadeStepSize, bool abLoop);
92 
97  void Stop(float afFadeStepSize);
98  void Pause();
99  void Resume();
100 
105  void Lock(cMusicLock *apLock);
109  void UnLock();
110  tString GetCurrentSongName();
111  float GetCurrentSongVolume();
112 
113  cMusicEntry *GetCurrentSong();
114 
115  void Update(float afTimeStep);
116 
117 private:
118  iLowLevelSound *mpLowLevelSound;
119  cResources *mpResources;
120 
121  tMusicEntryList mlstFadingSongs;
122  cMusicEntry *mpMainSong;
123  cMusicLock *mpLock;
124  bool mbIsPaused;
125 
126  bool LoadAndStart(const tString &asFileName, cMusicEntry *apSong, float afVolume, bool abLoop);
127 };
128 
129 } // namespace hpl
130 #endif // HPL_MUSICHANDLER_H
Definition: AI.h:36
Definition: str.h:59
Definition: MusicHandler.h:56
Definition: MusicHandler.h:78
Definition: MusicHandler.h:43
Definition: Resources.h:160
Definition: SoundChannel.h:46
Definition: LowLevelSound.h:45
Definition: list_intern.h:51