ScummVM API documentation
adlib.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 AGOS_SIMON1_ADLIB_H
23 #define AGOS_SIMON1_ADLIB_H
24 
25 #include "audio/adlib_ms.h"
26 
27 namespace AGOS {
28 
30 private:
31  struct RhythmMapEntry {
32  // The OPL rhythm instrument to use.
33  // The original interpreter would move a note played on the MIDI rhythm
34  // channel to one of MIDI channels 11-15, each corresponding to an OPL
35  // rhythm instrument.
36  uint8 channel;
37  // The instrument bank entry used to play the rhythm note.
38  uint8 program;
39  // The MIDI note number that is actually played.
40  uint8 note;
41  };
42 
43 public:
44  MidiDriver_Simon1_AdLib(OPL::Config::OplType oplType, const byte *instrumentData);
46 
47  int open() override;
48 
49  void noteOn(uint8 channel, uint8 note, uint8 velocity, uint8 source) override;
50  void programChange(uint8 channel, uint8 program, uint8 source) override;
51 
52  void deinitSource(uint8 source) override;
53 
54  // Turns off rhythm notes for sources with type MUSIC (typically source 0).
55  // This should be called when a SFX source that uses rhythm notes starts
56  // playing to prevent conflicts on the rhythm channels. Deinitializing a
57  // SFX source will turn rhythm notes back on.
58  void disableMusicRhythmNotes();
59 
60 private:
61  static const RhythmMapEntry RHYTHM_MAP[];
62  static const uint16 FREQUENCY_TABLE[];
63 
64  uint8 allocateOplChannel(uint8 channel, uint8 source, uint8 instrumentId) override;
65  uint16 calculateFrequency(uint8 channel, uint8 source, uint8 note) override;
66  uint8 calculateUnscaledVolume(uint8 channel, uint8 source, uint8 velocity,
67  OplInstrumentDefinition &instrumentDef, uint8 operatorNum) override;
68  void parseInstrumentData(const byte *instrumentData);
69 
70  // True if rhythm notes for sources with type MUSIC should not be played.
71  bool _musicRhythmNotesDisabled;
72 };
73 
74 MidiDriver_Multisource *createMidiDriverSimon1AdLib(const char *instrumentFilename, OPL::Config::OplType);
75 
76 } // End of namespace AGOS
77 
78 #endif
Definition: mididrv_ms.h:86
void programChange(uint8 channel, uint8 program, uint8 source) override
void deinitSource(uint8 source) override
Definition: adlib_ms.h:289
Definition: adlib.h:29
Definition: agos.h:70
OplType
Definition: fmopl.h:58
void noteOn(uint8 channel, uint8 note, uint8 velocity, uint8 source) override
Definition: adlib_ms.h:79