ScummVM API documentation
instrument.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 SCUMM_IMUSE_INSTRUMENT_H
23 #define SCUMM_IMUSE_INSTRUMENT_H
24 
25 
26 #include "common/scummsys.h"
27 #include "common/serializer.h"
28 
29 class MidiChannel;
30 
31 namespace Scumm {
32 
33 class Instrument;
34 
36 public:
37  ~InstrumentInternal() override {}
38  virtual void send(MidiChannel *mc) = 0;
39  virtual void copy_to(Instrument *dest) = 0;
40  virtual bool is_valid() = 0;
41 };
42 
44 private:
45  byte _type;
46  InstrumentInternal *_instrument;
47 
48 public:
49  enum {
50  itNone = 0,
51  itProgram = 1,
52  itAdLib = 2,
53  itRoland = 3,
54  itPcSpk = 4,
55  itMacSfx = 5
56  };
57 
58  Instrument() : _type(0), _instrument(0), _nativeMT32Device(false) { }
59  ~Instrument() override { delete _instrument; }
60  void setNativeMT32Mode(bool isNativeMT32) { _nativeMT32Device = isNativeMT32; }
61  static const byte _gmRhythmMap[35];
62 
63  void clear();
64  void copy_to(Instrument *dest) {
65  if (_instrument)
66  _instrument->copy_to(dest);
67  else
68  dest->clear();
69  }
70 
71  void program(byte program, bool mt32SoundType);
72  void adlib(const byte *instrument);
73  void roland(const byte *instrument);
74  void pcspk(const byte *instrument);
75  void macSfx(byte program);
76 
77  byte getType() { return _type; }
78  bool isValid() { return (_instrument ? _instrument->is_valid() : false); }
79  void saveLoadWithSerializer(Common::Serializer &s) override;
80  void send(MidiChannel *mc) {
81  if (_instrument)
82  _instrument->send(mc);
83  }
84 
85  bool _nativeMT32Device;
86 };
87 
88 } // End of namespace Scumm
89 
90 #endif
Definition: serializer.h:79
Definition: serializer.h:308
Definition: mididrv.h:537
Definition: instrument.h:35
Definition: instrument.h:43
Definition: actor.h:30