X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuffer.cpp;h=5aef1b4555081963d12da637ee5dfd199a75718a;hb=6cc0f1735a00e8f9eb80ff0c9468fb67205f6d20;hp=2a33b8329374c2075ead1a0a9f92d24c753ee86f;hpb=35ea5cc8d1eb8c806885d27441548f630e7b1266;p=libs%2Fal.git diff --git a/source/buffer.cpp b/source/buffer.cpp index 2a33b83..5aef1b4 100644 --- a/source/buffer.cpp +++ b/source/buffer.cpp @@ -1,12 +1,5 @@ -/* $Id$ - -This file is part of libmspal -Copyright © 2008 Mikko Rasa, Mikkosoft Productions -Diestributed 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