X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuffer.cpp;h=8e53964f930b783d52daaed06df09b91dcdc2eaf;hb=ef9906f379e066cb9c754853a3cc771e8e881356;hp=b2ef01698c948221877c312abfa476ce4f5326fa;hpb=8e69eba7dc53233c169152bdf654f032fcd0629f;p=libs%2Fal.git diff --git a/source/buffer.cpp b/source/buffer.cpp index b2ef016..8e53964 100644 --- a/source/buffer.cpp +++ b/source/buffer.cpp @@ -1,12 +1,6 @@ -/* $Id$ - -This file is part of libmspal -Copyright © 2008 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include #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