]> git.tdb.fi Git - libs/al.git/blob - source/sound.h
60bdf456319d4cf3298d74176c879aa62adb13fe
[libs/al.git] / source / sound.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 Sound
16 {
17 private:
18         OggVorbis_File ovfile;
19         unsigned freq;
20         unsigned size;
21         char *data;
22         Format format;
23         unsigned read_pos;
24         bool eof_flag;
25
26 public:
27         Sound();
28         ~Sound();
29
30         void open_file(const std::string &);
31         void open_memory(const void *, unsigned);
32 private:
33         void open_common();
34 public:
35         void load_data();
36         void load_file(const std::string &);
37         void load_memory(const void *, unsigned);
38         void close();
39         void rewind();
40         unsigned read(char *, unsigned);
41         bool eof() const { return eof_flag; }
42
43         Format get_format() const { return format; }
44         unsigned get_frequency() const { return freq; }
45         unsigned get_size() const { return size; }
46         const char *get_data() const;
47 };
48
49 } // namespace AL
50 } // namespace Msp
51
52 #endif