]> git.tdb.fi Git - libs/al.git/blob - source/sound.h
Bump version for release
[libs/al.git] / source / sound.h
1 /* $Id$
2
3 This file is part of libmspal
4 Copyright © 2008 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_AL_SOUND_H_
9 #define MSP_AL_SOUND_H_
10
11 #include <string>
12 #include <vorbis/vorbisfile.h>
13 #include "format.h"
14
15 namespace Msp {
16 namespace AL {
17
18 /**
19 This class facilitates loading sound files.  Currently only Ogg Vorbis is
20 supported.
21 */
22 class Sound
23 {
24 private:
25         OggVorbis_File ovfile;
26         unsigned freq;
27         unsigned size;
28         char *data;
29         Format format;
30         unsigned read_pos;
31         bool eof_flag;
32
33 public:
34         Sound();
35         ~Sound();
36
37         void open_file(const std::string &);
38         void open_memory(const void *, unsigned);
39         void load_data();
40         void load_file(const std::string &);
41         void load_memory(const void *, unsigned);
42         void close();
43         void rewind();
44         unsigned read(char *, unsigned);
45         bool eof() const { return eof_flag; }
46
47         Format get_format() const { return format; }
48         unsigned get_frequency() const { return freq; }
49         unsigned get_size() const { return size; }
50         const char *get_data() const;
51 private:
52         void open_common();
53 };
54
55 } // namespace AL
56 } // namespace Msp
57
58 #endif