]> git.tdb.fi Git - libs/al.git/blobdiff - source/buffer.cpp
Split Sound into SoundDecoder and Waveform parts
[libs/al.git] / source / buffer.cpp
index b2ef01698c948221877c312abfa476ce4f5326fa..5aef1b4555081963d12da637ee5dfd199a75718a 100644 (file)
@@ -1,12 +1,5 @@
-/* $Id$
-
-This file is part of libmspal
-Copyright © 2008 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include "buffer.h"
-#include "sound.h"
+#include "waveform.h"
 
 using namespace std;
 
@@ -28,12 +21,32 @@ void Buffer::data(Format fmt, const void *dt, sizei size, sizei freq)
        alBufferData(id, fmt, dt, size, freq);
 }
 
+void Buffer::data(const Waveform &wave)
+{
+       data(wave.get_format(), wave.get_data(), wave.get_size(), wave.get_frequency());
+}
+
 void Buffer::load_data(const string &fn)
 {
-       Sound sound;
-       sound.load(fn);
+       Waveform wave;
+       wave.load_file(fn);
+
+       data(wave);
+}
+
+
+Buffer::Loader::Loader(Buffer &b):
+       buf(b)
+{
+       add("sound_data", &Loader::sound_data);
+}
+
+void Buffer::Loader::sound_data(const string &data)
+{
+       Waveform wave;
+       wave.load_memory(data.data(), data.size());
 
-       data(sound.get_format(), sound.get_data(), sound.get_size(), sound.get_frequency());
+       buf.data(wave);
 }
 
 } // namespace AL