]> git.tdb.fi Git - libs/al.git/blobdiff - source/buffer.cpp
Use Msp::IO in SoundDecoder
[libs/al.git] / source / buffer.cpp
index 2a33b8329374c2075ead1a0a9f92d24c753ee86f..8e53964f930b783d52daaed06df09b91dcdc2eaf 100644 (file)
@@ -1,12 +1,6 @@
-/* $Id$
-
-This file is part of libmspal
-Copyright © 2008 Mikko Rasa, Mikkosoft Productions
-Diestributed under the LGPL
-*/
-
+#include <msp/io/memory.h>
 #include "buffer.h"
-#include "sound.h"
+#include "waveform.h"
 
 using namespace std;
 
@@ -28,12 +22,33 @@ 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;
+       IO::Memory mem(data.data(), data.size());
+       wave.load_io(mem);
 
-       data(sound.get_format(), sound.get_data(), sound.get_size(), sound.get_frequency());
+       buf.data(wave);
 }
 
 } // namespace AL