ScummVM API documentation
midi.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef M4_SOUND_PLATFORM_MIDI_H
24 #define M4_SOUND_PLATFORM_MIDI_H
25 
26 #include "audio/mididrv_ms.h"
27 #include "audio/midiparser.h"
28 
29 namespace M4 {
30 namespace Sound {
31 
32 class Midi {
33 private:
34  // Trigger to fire once the current track has finished, or -1 for none.
35  // _pendingEndTrigger hands it from the audio thread to the main thread.
36  int _midiEndTrigger;
37  int _pendingEndTrigger;
38 
39  Common::Mutex _mutex;
40 
41  MusicType _deviceType;
42 
43  MidiDriver_Multisource *_driver;
44  MidiParser *_midiParser;
45  byte *_midiData;
46 
47  bool _paused;
48 
49 protected:
50  static void onTimer(void *data);
51 
52 public:
53  Midi();
54  ~Midi();
55 
56  int open();
57 
58  void load(byte *in, int32 size);
59  void play();
60  void pause(bool pause);
61  void stop();
62  bool isPlaying();
63  void startFade(uint16 duration, uint16 targetVolume);
64  bool isFading();
65 
66  void syncSoundSettings();
67 
68  void midi_play(const char *name, int volume, bool loop, int trigger, int roomNum);
69  void task();
70  void loop();
71  void midi_fade_volume(int targetVolume, int duration);
72 };
73 
74 } // namespace Sound
75 
76 void midi_play(const char *name, int volume, bool loop, int trigger, int roomNum);
77 void midi_loop();
78 void midi_stop();
79 void midi_fade_volume(int targetVolume, int duration);
80 
81 } // namespace M4
82 
83 #endif
Definition: mididrv_ms.h:86
MusicType
Definition: mididrv.h:44
Definition: midi.h:32
Definition: mutex.h:67
Definition: database.h:28
Definition: midiparser.h:354