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 QUEEN_MUSIC_H
23 #define QUEEN_MUSIC_H
24 
25 #include "common/util.h"
26 #include "common/mutex.h"
27 #include "common/random.h"
28 #include "audio/mididrv.h"
29 
30 class MidiParser;
31 
32 namespace Queen {
33 
34 struct TuneData;
35 
36 class QueenEngine;
37 
38 class MidiMusic : public MidiDriver_BASE {
39 public:
41  ~MidiMusic() override;
42  void setVolume(int volume);
43  int getVolume() const { return _masterVolume; }
44 
45  void playSong(uint16 songNum);
46  void stopSong() { stopMusic(); }
47  void playMusic();
48  void stopMusic();
49  void setLoop(bool loop) { _isLooping = loop; }
50  void queueTuneList(int16 tuneList);
51  bool queueSong(uint16 songNum);
52  void queueClear();
53  void toggleVChange();
54 
55  // MidiDriver_BASE interface implementation
56  void send(uint32 b) override;
57  void metaEvent(byte type, byte *data, uint16 length) override;
58 
59 protected:
60 
61  enum {
62  MUSIC_QUEUE_SIZE = 14
63  };
64 
65  void queueUpdatePos();
66  uint8 randomQueuePos();
67  void onTimer();
68  uint32 songOffset(uint16 songNum) const;
69  uint32 songLength(uint16 songNum) const;
70 
71  static void timerCallback(void *refCon) { ((MidiMusic *)refCon)->onTimer(); }
72 
73  MidiDriver *_driver;
74  MidiParser *_parser;
75  MidiChannel *_channelsTable[16];
76  byte _channelsVolume[16];
77  bool _adlib;
78  bool _nativeMT32;
79  Common::Mutex _mutex;
81 
82  bool _isPlaying;
83  bool _isLooping;
84  bool _randomLoop;
85  byte _masterVolume;
86  uint8 _queuePos;
87  int16 _currentSong;
88  int16 _lastSong; //first song from previous queue
89  int16 _songQueue[MUSIC_QUEUE_SIZE];
90 
91  uint16 _numSongs;
92  uint16 *_buf;
93  uint32 _musicDataSize;
94  bool _vToggle;
95  byte *_musicData;
96  const TuneData *_tune;
97 };
98 
99 } // End of namespace Queen
100 
101 #endif
Definition: queen.h:62
Definition: random.h:44
Definition: mididrv.h:309
Definition: bankman.h:28
Definition: mididrv.h:112
void send(uint32 b) override
Definition: mutex.h:67
Definition: sound.h:46
Definition: mididrv.h:537
Definition: music.h:38
Definition: midiparser.h:289