]> git.tdb.fi Git - libs/al.git/blobdiff - source/buffer.cpp
Initial revision
[libs/al.git] / source / buffer.cpp
diff --git a/source/buffer.cpp b/source/buffer.cpp
new file mode 100644 (file)
index 0000000..2a33b83
--- /dev/null
@@ -0,0 +1,40 @@
+/* $Id$
+
+This file is part of libmspal
+Copyright © 2008 Mikko Rasa, Mikkosoft Productions
+Diestributed under the LGPL
+*/
+
+#include "buffer.h"
+#include "sound.h"
+
+using namespace std;
+
+namespace Msp {
+namespace AL {
+
+Buffer::Buffer()
+{
+       alGenBuffers(1, &id);
+}
+
+Buffer::~Buffer()
+{
+       alDeleteBuffers(1, &id);
+}
+
+void Buffer::data(Format fmt, const void *dt, sizei size, sizei freq)
+{
+       alBufferData(id, fmt, dt, size, freq);
+}
+
+void Buffer::load_data(const string &fn)
+{
+       Sound sound;
+       sound.load(fn);
+
+       data(sound.get_format(), sound.get_data(), sound.get_size(), sound.get_frequency());
+}
+
+} // namespace AL
+} // namespace Msp