1 /*
2 BStone: A Source port of
3 Blake Stone: Aliens of Gold and Blake Stone: Planet Strike
4 
5 Copyright (c) 1992-2013 Apogee Entertainment, LLC
6 Copyright (c) 2013-2015 Boris I. Bendovsky (bibendovsky@hotmail.com)
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the
20 Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 */
23 
24 
25 //
26 // A decoder for AdLib music.
27 //
28 
29 
30 #ifndef BSTONE_ADLIB_MUSIC_DECODER_INCLUDED
31 #define BSTONE_ADLIB_MUSIC_DECODER_INCLUDED
32 
33 
34 #include <cstdint>
35 #include <vector>
36 #include "bstone_adlib_decoder.h"
37 #include "bstone_memory_binary_reader.h"
38 
39 
40 namespace bstone {
41 
42 
43 // A decoder for AdLib music.
44 class AdlibMusicDecoder : public AdlibDecoder {
45 public:
46     AdlibMusicDecoder();
47 
48     virtual ~AdlibMusicDecoder();
49 
50     virtual bool initialize(
51         const void* raw_data,
52         int raw_size,
53         int dst_rate);
54 
55     virtual void uninitialize();
56 
57     virtual bool reset();
58 
59     virtual AudioDecoder* clone();
60 
61     virtual int decode(
62         int dst_count,
63         int16_t* dst_data);
64 
65     // Returns a number of calls per second of
66     // original interrupt routine.
67     static int get_tick_rate();
68 
69 private:
70     MemoryBinaryReader reader_;
71     int commands_count_;
72     int command_index_;
73     int samples_per_tick_;
74     int remains_count_;
75 }; // AdlibDecoder
76 
77 
78 } // bstone
79 
80 
81 #endif // BSTONE_ADLIB_MUSIC_DECODER_INCLUDED
82