ScummVM API documentation
midiplayer.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 AUDIO_MIDIPLAYER_H
23 #define AUDIO_MIDIPLAYER_H
24 
25 #include "common/scummsys.h"
26 #include "common/mutex.h"
27 #include "audio/mididrv.h"
28 
29 class MidiParser;
30 
31 namespace Audio {
32 
63 class MidiPlayer : public MidiDriver_BASE {
64 public:
65  MidiPlayer();
66  ~MidiPlayer();
67 
68  // TODO: Implement ways to actually play stuff
69  //virtual void play(TODO);
70 
71  // TODO: Document these
72  virtual void stop();
73  virtual void pause();
74  virtual void resume();
75 
94  bool isPlaying() const { return _isPlaying; }
95 
99  int getVolume() const { return _masterVolume; }
100 
113  virtual void setVolume(int volume);
114 
119  void syncVolume();
120 
121  // TODO: Document this
122  bool hasNativeMT32() const { return _nativeMT32; }
123 
124  // MidiDriver_BASE implementation
125  void send(uint32 b) override;
126  void metaEvent(byte type, byte *data, uint16 length) override;
127 
128 protected:
133  virtual void sendToChannel(byte ch, uint32 b);
134 
142  virtual void endOfTrack();
143 
144  // TODO: Document this
145  virtual void onTimer();
146 
147  static void timerCallback(void *data);
148 
149  void createDriver(int flags = MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM);
150 
151 protected:
152  enum {
157  };
158 
159  Common::Mutex _mutex;
160  MidiDriver *_driver;
161 
169 
176  byte *_midiData;
177 
178  MidiChannel *_channelsTable[kNumChannels];
179  uint8 _channelsVolume[kNumChannels];
180 
181  bool _isLooping;
182  bool _isPlaying;
183 
187  int _masterVolume; // FIXME: byte or int ?
188 
189  bool _nativeMT32;
190 };
191 
193 } // End of namespace Audio
194 
195 #endif
int _masterVolume
Definition: midiplayer.h:187
Definition: midiplayer.h:63
MidiParser * _parser
Definition: midiplayer.h:168
bool isPlaying() const
Definition: midiplayer.h:94
void send(uint32 b) override
virtual void setVolume(int volume)
Definition: mididrv.h:309
virtual void endOfTrack()
int getVolume() const
Definition: midiplayer.h:99
Definition: mididrv.h:112
Definition: mutex.h:67
Definition: mididrv.h:537
Definition: midiplayer.h:156
byte * _midiData
Definition: midiplayer.h:176
virtual void sendToChannel(byte ch, uint32 b)
Definition: system.h:38
Definition: midiparser.h:289