]> git.tdb.fi Git - libs/al.git/blob - source/buffer.cpp
Drop copyright notices and Id tags from source files
[libs/al.git] / source / buffer.cpp
1 #include "buffer.h"
2 #include "sound.h"
3
4 using namespace std;
5
6 namespace Msp {
7 namespace AL {
8
9 Buffer::Buffer()
10 {
11         alGenBuffers(1, &id);
12 }
13
14 Buffer::~Buffer()
15 {
16         alDeleteBuffers(1, &id);
17 }
18
19 void Buffer::data(Format fmt, const void *dt, sizei size, sizei freq)
20 {
21         alBufferData(id, fmt, dt, size, freq);
22 }
23
24 void Buffer::data(const Sound &snd)
25 {
26         data(snd.get_format(), snd.get_data(), snd.get_size(), snd.get_frequency());
27 }
28
29 void Buffer::load_data(const string &fn)
30 {
31         Sound sound;
32         sound.load_file(fn);
33
34         data(sound);
35 }
36
37
38 Buffer::Loader::Loader(Buffer &b):
39         buf(b)
40 {
41         add("sound_data", &Loader::sound_data);
42 }
43
44 void Buffer::Loader::sound_data(const string &data)
45 {
46         Sound sound;
47         sound.load_memory(data.data(), data.size());
48
49         buf.data(sound);
50 }
51
52 } // namespace AL
53 } // namespace Msp