]> git.tdb.fi Git - libs/al.git/blob - source/sound.h
Drop copyright notices and Id tags from source files
[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         void load_data();
33         void load_file(const std::string &);
34         void load_memory(const void *, unsigned);
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         const char *get_data() const;
44 private:
45         void open_common();
46 };
47
48 } // namespace AL
49 } // namespace Msp
50
51 #endif