ScummVM API documentation
musicbase.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 SKY_MUSIC_MUSICBASE_H
23 #define SKY_MUSIC_MUSICBASE_H
24 
25 
26 #include "common/scummsys.h"
27 #include "common/mutex.h"
28 
29 #include "audio/mixer.h"
30 
31 namespace Sky {
32 
33 class Disk;
34 
35 #define FILES_PER_SECTION 4
36 
37 typedef struct {
38  uint8 musicToProcess;
39 } Actions;
40 
41 class ChannelBase {
42 public:
43  virtual ~ChannelBase() {}
44  virtual uint8 process(uint16 aktTime) = 0;
45  virtual void updateVolume(uint16 pVolume) = 0;
46  virtual bool isActive() = 0;
47 private:
48 };
49 
50 class MusicBase {
51 public:
52  MusicBase(Audio::Mixer *pMixer, Disk *pDisk);
53  virtual ~MusicBase();
54  void loadSection(uint8 pSection);
55  void startMusic(uint16 param);
56  void stopMusic();
57  bool musicIsPlaying();
58  uint8 giveVolume();
59  uint8 giveCurrentMusic();
60  virtual void setVolume(uint16 param) = 0;
61 
62 protected:
63 
64  Audio::Mixer *_mixer;
65  Disk *_skyDisk;
66  uint8 *_musicData;
67 
68  uint16 _musicDataLoc;
69  uint16 _driverFileBase;
70 
71  uint16 _musicVolume, _numberOfChannels;
72  uint8 _currentMusic, _currentSection;
73  uint8 _musicTempo0; // can be changed by music stream
74  uint8 _musicTempo1; // given once per music
75  uint32 _tempo; // calculated from musicTempo0 and musicTempo1
76  uint32 _aktTime;
77  Actions _onNextPoll;
78  ChannelBase *_channels[10];
79  Common::Mutex _mutex;
80  Audio::SoundHandle _musicHandle;
81 
82  virtual void setupPointers() = 0;
83  virtual void setupChannels(uint8 *channelData) = 0;
84  virtual void startDriver() = 0;
85 
86  void updateTempo();
87  void loadNewMusic();
88  void pollMusic();
89 
90  void stopMusicInternal();
91 };
92 
93 } // End of namespace Sky
94 
95 #endif //MUSICBASE_H
Definition: musicbase.h:37
Definition: musicbase.h:50
Definition: disk.h:37
Definition: mixer.h:49
Definition: mixer.h:59
Definition: musicbase.h:41
Definition: mutex.h:67
Definition: autoroute.h:28