ScummVM API documentation
midiparser_sci.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 DGDS_SOUND_MIDIPARSER_H
23 #define DGDS_SOUND_MIDIPARSER_H
24 
25 #include "dgds/sound/music.h"
26 #include "dgds/sound/resource/sci_resource.h"
27 #include "audio/midiparser.h"
28 
29 /*
30  Sound drivers info: (from driver cmd0)
31  AdLib/SB : track 0 , voices 9 , patch 3 ah=1
32  ProAudioSp: track 0 , voices 9 , patch 3 ah=17
33  GenerlMIDI: track 7 , voices 32, patch 4 ah=1 SCI1.1
34  Game Blast: track 9 , voices 12, patch 101 ah=1
35  MT-32 : track 12, voices 32, patch 1 ah=1
36  PC Speaker: track 18, voices 1 , patch 0xFF ah=1
37  Tandy : track 19, voices 3 , patch 101 ah=1
38  IBM PS/1 : track 19, voices 3 , patch 101 ah=1
39  */
40 
41 namespace Dgds {
42 
49 class MidiParser_SCI : public MidiParser {
50 public:
51  MidiParser_SCI(SciMusic *music);
52  ~MidiParser_SCI() override;
53 
54  void mainThreadBegin();
55  void mainThreadEnd();
56 
57  bool loadMusic(SoundResource::Track *track, MusicEntry *psnd, int channelFilterMask);
58  bool loadMusic(byte *, uint32) override {
59  return false;
60  }
61  void initTrack();
62  void sendInitCommands();
63  void unloadMusic() override;
64  void setMasterVolume(byte masterVolume);
65  void setVolume(byte volume);
66  void stop() {
67  _abortParse = true;
68  allNotesOff();
69  }
70  void pause() {
71  allNotesOff();
72  if (_resetOnPause)
73  jumpToTick(0);
74  }
75 
76  void allNotesOff() override;
77 
78  const SciSpan<const byte> &getMixedData() const { return *_mixedData; }
79  byte getSongReverb();
80 
81  void sendFromScriptToDriver(uint32 midi);
82  void sendToDriver(uint32 midi) override;
83  void sendToDriver(byte status, byte firstOp, byte secondOp) {
84  sendToDriver(status | ((uint32)firstOp << 8) | ((uint32)secondOp << 16));
85  }
86 
87  void remapChannel(int channel, int devChannel);
88 
89 protected:
90  void parseNextEvent(EventInfo &info) override;
91  bool processEvent(const EventInfo &info, bool fireEvents = true) override;
92  void midiMixChannels();
93  byte midiGetNextChannel(long ticker);
94  void resetStateTracking();
95  void trackState(uint32 midi);
96  void sendToDriver_raw(uint32 midi);
97 
98  SciMusic *_music;
99 
100  // this is set, when main thread calls us -> we send commands to queue instead to driver
101  bool _mainThreadCalled;
102 
104  SoundResource::Track *_track;
105  MusicEntry *_pSnd;
106  uint32 _loopTick;
107  byte _masterVolume; // the overall master volume (same for all tracks)
108  byte _volume; // the global volume of the current track
109 
110  bool _resetOnPause;
111 
112  bool _channelUsed[16];
113  int16 _channelRemap[16];
114  byte _channelVolume[16];
115 
116  struct ChannelState {
117  int8 _modWheel;
118  int8 _pan;
119  int8 _patch;
120  int8 _note;
121  bool _sustain;
122  int16 _pitchWheel;
123  int8 _voices;
124  };
125 
126  ChannelState _channelState[16];
127 
128 };
129 
130 } // End of namespace Dgds
131 
132 #endif // DGDS_SOUND_MIDIPARSER_H
Definition: sci_resource.h:74
Definition: music.h:77
Definition: ads.h:28
Definition: midiparser_sci.h:49
Definition: midiparser.h:84
Definition: music.h:178
Definition: span.h:892
bool _abortParse
If a jump or other operation interrupts parsing, flag to abort.
Definition: midiparser.h:318
Definition: midiparser_sci.h:116
Definition: midiparser.h:289