1 #ifndef GAME_SOUND_SOUND_DECODER_H
2 #define GAME_SOUND_SOUND_DECODER_H
3 
4 #include <string>
5 #include <vector>
6 
7 namespace VFS
8 {
9     class Manager;
10 }
11 
12 namespace MWSound
13 {
14     enum SampleType {
15         SampleType_UInt8,
16         SampleType_Int16,
17         SampleType_Float32
18     };
19     const char *getSampleTypeName(SampleType type);
20 
21     enum ChannelConfig {
22         ChannelConfig_Mono,
23         ChannelConfig_Stereo,
24         ChannelConfig_Quad,
25         ChannelConfig_5point1,
26         ChannelConfig_7point1
27     };
28     const char *getChannelConfigName(ChannelConfig config);
29 
30     size_t framesToBytes(size_t frames, ChannelConfig config, SampleType type);
31     size_t bytesToFrames(size_t bytes, ChannelConfig config, SampleType type);
32 
33     struct Sound_Decoder
34     {
35         const VFS::Manager* mResourceMgr;
36 
37         virtual void open(const std::string &fname) = 0;
38         virtual void close() = 0;
39 
40         virtual std::string getName() = 0;
41         virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) = 0;
42 
43         virtual size_t read(char *buffer, size_t bytes) = 0;
44         virtual void readAll(std::vector<char> &output);
45         virtual size_t getSampleOffset() = 0;
46 
Sound_DecoderMWSound::Sound_Decoder47         Sound_Decoder(const VFS::Manager* resourceMgr) : mResourceMgr(resourceMgr)
48         { }
~Sound_DecoderMWSound::Sound_Decoder49         virtual ~Sound_Decoder() { }
50 
51     private:
52         Sound_Decoder(const Sound_Decoder &rhs);
53         Sound_Decoder& operator=(const Sound_Decoder &rhs);
54     };
55 }
56 
57 #endif
58