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 SCI_SOUND_MIDIPARSER_H
23 #define SCI_SOUND_MIDIPARSER_H
24 
25 #include "sci/resource/resource.h"
26 #include "sci/sound/music.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 
42 namespace Sci {
43 
50 class MidiParser_SCI : public MidiParser {
51 public:
52  MidiParser_SCI(SciVersion soundVersion, SciMusic *music);
53  ~MidiParser_SCI() override;
54 
55  void mainThreadBegin();
56  void mainThreadEnd();
57 
58  bool loadMusic(SoundResource::Track *track, MusicEntry *psnd, int channelFilterMask, SciVersion soundVersion);
59  bool loadMusic(byte *, uint32) override {
60  return false;
61  }
62  void initTrack();
63  void sendInitCommands();
64  void unloadMusic() override;
65  void setMasterVolume(byte masterVolume);
66  void setVolume(byte volume);
67  void stop() {
68  _abortParse = true;
69  allNotesOff();
70  }
71  void pause() {
72  allNotesOff();
73  if (_resetOnPause)
74  jumpToTick(0);
75  }
76 
77  void allNotesOff() override;
78 
79  const SciSpan<const byte> &getMixedData() const { return *_mixedData; }
80  byte getSongReverb();
81 
82  void sendFromScriptToDriver(uint32 midi);
83  void sendToDriver(uint32 midi) override;
84  void sendToDriver(byte status, byte firstOp, byte secondOp) {
85  sendToDriver(status | ((uint32)firstOp << 8) | ((uint32)secondOp << 16));
86  }
87 
88  void remapChannel(int channel, int devChannel);
89 
90 protected:
91  void parseNextEvent(EventInfo &info) override;
92  bool processEvent(const EventInfo &info, bool fireEvents = true) override;
93  void midiMixChannels();
94  void midiFilterChannels(int channelMask);
95  byte midiGetNextChannel(long ticker);
96  void resetStateTracking();
97  void trackState(uint32 midi);
98  void sendToDriver_raw(uint32 midi);
99 
100  SciMusic *_music;
101 
102  // this is set, when main thread calls us -> we send commands to queue instead to driver
103  bool _mainThreadCalled;
104 
105  SciVersion _soundVersion;
107  SoundResource::Track *_track;
108  MusicEntry *_pSnd;
109  uint32 _loopTick;
110  byte _masterVolume; // the overall master volume (same for all tracks)
111  byte _volume; // the global volume of the current track
112 
113  bool _resetOnPause;
114 
115  bool _channelUsed[16];
116  int16 _channelRemap[16];
117  byte _channelVolume[16];
118 
119  struct ChannelState {
120  int8 _modWheel;
121  int8 _pan;
122  int8 _patch;
123  int8 _note;
124  bool _sustain;
125  int16 _pitchWheel;
126  int8 _voices;
127  };
128 
129  ChannelState _channelState[16];
130 };
131 
132 } // End of namespace Sci
133 
134 #endif // SCI_SOUND_MIDIPARSER_H
SciVersion
Definition: detection.h:135
Definition: resource.h:694
Definition: music.h:176
Definition: midiparser.h:84
Definition: span.h:892
Definition: midiparser_sci.h:119
Definition: midiparser_sci.h:50
Definition: console.h:28
bool _abortParse
If a jump or other operation interrupts parsing, flag to abort.
Definition: midiparser.h:318
Definition: music.h:72
Definition: midiparser.h:289