]> git.tdb.fi Git - libs/al.git/blob - source/sounddecoder.h
Use Msp::IO in SoundDecoder
[libs/al.git] / source / sounddecoder.h
1 #ifndef MSP_AL_SOUND_H_
2 #define MSP_AL_SOUND_H_
3
4 #include <string>
5 #include <vorbis/vorbisfile.h>
6 #include <msp/io/seekable.h>
7 #include "format.h"
8
9 namespace Msp {
10 namespace AL {
11
12 /**
13 This class facilitates loading sound files.  Currently only Ogg Vorbis is
14 supported.
15 */
16 class SoundDecoder
17 {
18 private:
19         OggVorbis_File ovfile;
20         IO::Seekable *source;
21         unsigned freq;
22         unsigned size;
23         Format format;
24         bool eof_flag;
25
26 public:
27         SoundDecoder();
28         ~SoundDecoder();
29
30         void open_file(const std::string &);
31         void open_io(IO::Seekable &);
32 private:
33         void open_common();
34 public:
35         void close();
36         void rewind();
37         unsigned read(char *, unsigned);
38         bool eof() const { return eof_flag; }
39
40         Format get_format() const { return format; }
41         unsigned get_frequency() const { return freq; }
42         unsigned get_size() const { return size; }
43 };
44
45 } // namespace AL
46 } // namespace Msp
47
48 #endif