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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef GOB_SOUND_ADLPLAYER_H
24 #define GOB_SOUND_ADLPLAYER_H
25 
26 #include "common/array.h"
27 
28 #include "gob/sound/adlib.h"
29 
30 namespace Common {
31 	class SeekableReadStream;
32 }
33 
34 namespace Gob {
35 
36 /** A player for Coktel Vision's ADL music format. */
37 class ADLPlayer : public AdLib {
38 public:
39 	ADLPlayer();
40 	~ADLPlayer();
41 
42 	bool load(Common::SeekableReadStream &adl);
43 	bool load(const byte *data, uint32 dataSize, int index = -1);
44 	void unload();
45 
46 	int getIndex() const;
47 
48 protected:
49 	// AdLib interface
50 	uint32 pollMusic(bool first);
51 	void rewind();
52 
53 private:
54 	struct Timbre {
55 		uint16 startParams[kOperatorsPerVoice * kParamCount];
56 		uint16 params[kOperatorsPerVoice * kParamCount];
57 	};
58 
59 	uint8 _soundMode;
60 
61 	Common::Array<Timbre> _timbres;
62 
63 	byte  *_songData;
64 	uint32 _songDataSize;
65 
66 	const byte *_playPos;
67 
68 	int _index;
69 
70 	uint8  _modifyInstrument;
71 	uint16 _currentInstruments[kMaxVoiceCount];
72 
73 
74 	void setInstrument(int voice, int instrument);
75 
76 	bool readHeader  (Common::SeekableReadStream &adl, int &timbreCount);
77 	bool readTimbres (Common::SeekableReadStream &adl, int  timbreCount);
78 	bool readSongData(Common::SeekableReadStream &adl);
79 };
80 
81 } // End of namespace Gob
82 
83 #endif // GOB_SOUND_ADLPLAYER_H
84