ScummVM API documentation
musplayer.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  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_SOUND_MUSPLAYER_H
29 #define GOB_SOUND_MUSPLAYER_H
30 
31 #include "common/str.h"
32 #include "common/array.h"
33 
34 #include "gob/sound/adlib.h"
35 
36 namespace Common {
37  class SeekableReadStream;
38 }
39 
40 namespace Gob {
41 
46 class MUSPlayer : public AdLib {
47 public:
48  MUSPlayer();
49  ~MUSPlayer() override;
50 
52  bool loadSND(Common::SeekableReadStream &snd);
54  bool loadMUS(Common::SeekableReadStream &mus);
55 
56  void unload();
57 
58  uint32 getSongID() const;
59  const Common::String &getSongName() const;
60 
61 protected:
62  // AdLib interface
63  uint32 pollMusic(bool first) override;
64  void rewind() override;
65 
66 private:
67  struct Timbre {
68  Common::String name;
69 
70  uint16 params[kOperatorsPerVoice * kParamCount];
71  };
72 
73  Common::Array<Timbre> _timbres;
74 
75  byte *_songData;
76  uint32 _songDataSize;
77 
78  const byte *_playPos;
79 
80  uint32 _songID;
81  Common::String _songName;
82 
83  uint8 _ticksPerBeat;
84  uint8 _beatsPerMeasure;
85 
86  uint8 _soundMode;
87  uint8 _pitchBendRange;
88 
89  uint16 _baseTempo;
90 
91  uint16 _tempo;
92 
93  byte _lastCommand;
94 
95 
96  void unloadSND();
97  void unloadMUS();
98 
99  bool readSNDHeader (Common::SeekableReadStream &snd, int &timbreCount, int &timbrePos);
100  bool readSNDTimbres(Common::SeekableReadStream &snd, int timbreCount, int timbrePos);
101 
102  bool readMUSHeader(Common::SeekableReadStream &mus);
103  bool readMUSSong (Common::SeekableReadStream &mus);
104 
105  void setInstrument(uint8 voice, uint8 instrument);
106  void skipToTiming();
107 
108  static bool readString(Common::SeekableReadStream &stream, Common::String &string, byte *buffer, uint size);
109 };
110 
111 } // End of namespace Gob
112 
113 #endif // GOB_SOUND_MUSPLAYER_H
Definition: str.h:59
Definition: stream.h:745
Definition: anifile.h:40
Definition: musplayer.h:46
Definition: algorithm.h:29
Definition: adlib.h:42