ScummVM API documentation
music.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 SHERLOCK_MUSIC_H
23 #define SHERLOCK_MUSIC_H
24 
25 #include "audio/midiparser.h"
26 #include "audio/mididrv.h"
27 // for 3DO digital music
28 #include "audio/mixer.h"
29 #include "common/mutex.h"
30 #include "common/str-array.h"
31 
32 namespace Sherlock {
33 
34 class SherlockEngine;
35 
36 class MidiParser_SH : public MidiParser {
37 public:
38  MidiParser_SH();
39  ~MidiParser_SH() override;
40 
41 protected:
42  Common::Mutex _mutex;
43  void parseNextEvent(EventInfo &info) override;
44 
45  uint8 _beats;
46  uint8 _lastEvent;
47  byte *_data;
48  byte *_trackEnd;
49 
50 public:
51  bool loadMusic(byte *musData, uint32 musSize) override;
52  void unloadMusic() override;
53 
54 private:
55  byte *_musData;
56  uint32 _musDataSize;
57 };
58 
59 class Music {
60 private:
61  SherlockEngine *_vm;
62  Audio::Mixer *_mixer;
63  MidiParser *_midiParser;
64  MidiDriver *_midiDriver;
65  Audio::SoundHandle _digitalMusicHandle;
66  MusicType _musicType;
67  byte *_midiMusicData;
68 
72  bool playMusic(const Common::String &name);
73 public:
74  bool _musicPlaying;
75  bool _musicOn;
76  int _musicVolume;
77  bool _midiOption;
78  Common::String _currentSongName, _nextSongName;
79 public:
80  Music(SherlockEngine *vm, Audio::Mixer *mixer);
81  ~Music();
82 
86  void syncMusicSettings();
87 
91  bool loadSong(int songNumber);
92 
96  bool loadSong(const Common::String &songName);
97 
101  void startSong();
102 
106  void freeSong();
107 
111  void stopMusic();
112 
113  bool isPlaying();
114  uint32 getCurrentPosition();
115 
116  bool waitUntilMSec(uint32 msecTarget, uint32 maxMSec, uint32 additionalDelay, uint32 noMusicDelay);
117 
121  void setMusicVolume(int volume);
122 
126  void getSongNames(Common::StringArray &songs);
127 
132  void checkSongProgress();
133 };
134 
135 } // End of namespace Sherlock
136 
137 #endif
Definition: str.h:59
Definition: music.h:36
Definition: animation.h:29
MusicType
Definition: mididrv.h:44
Definition: midiparser.h:84
Definition: mididrv.h:309
Definition: mixer.h:49
Definition: mixer.h:59
Definition: sherlock.h:76
Definition: mutex.h:67
Definition: music.h:59
Definition: midiparser.h:289