]> git.tdb.fi Git - libs/al.git/blob - source/sounddecoder.h
Split Sound into SoundDecoder and Waveform parts
[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 "format.h"
7
8 namespace Msp {
9 namespace AL {
10
11 /**
12 This class facilitates loading sound files.  Currently only Ogg Vorbis is
13 supported.
14 */
15 class SoundDecoder
16 {
17 private:
18         OggVorbis_File ovfile;
19         unsigned freq;
20         unsigned size;
21         Format format;
22         bool eof_flag;
23
24 public:
25         SoundDecoder();
26         ~SoundDecoder();
27
28         void open_file(const std::string &);
29         void open_memory(const void *, unsigned);
30 private:
31         void open_common();
32 public:
33         void close();
34         void rewind();
35         unsigned read(char *, unsigned);
36         bool eof() const { return eof_flag; }
37
38         Format get_format() const { return format; }
39         unsigned get_frequency() const { return freq; }
40         unsigned get_size() const { return size; }
41 };
42
43 } // namespace AL
44 } // namespace Msp
45
46 #endif