From 4a2bad92171ff8a9a248599f47087cfe39e93653 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 18 May 2008 09:21:20 +0000 Subject: OpenAL support --- src/audio/pcm.cc | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/audio/pcm.cc (limited to 'src/audio/pcm.cc') diff --git a/src/audio/pcm.cc b/src/audio/pcm.cc new file mode 100644 index 0000000..b485199 --- /dev/null +++ b/src/audio/pcm.cc @@ -0,0 +1,49 @@ +/* + audio/pcm.cc + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#include +#include + +#include "audio/pcm.h" +#include "audio/wav.h" + +namespace audio { + +PCM::PCM(unsigned int samplerate, unsigned int bitspersample, unsigned int channels, size_t size) +{ + pcm_bitspersample = bitspersample; + pcm_samplerate = samplerate; + pcm_size = size; + pcm_channels = channels; + + pcm_data = (unsigned char *) malloc(pcm_size); + clear(); +} + +PCM::~PCM() +{ + free(pcm_data); +} + +void PCM::clear() +{ + memset(pcm_data, 0, pcm_size); +} + +void PCM::load(const char *name) +{ + PCM *pcm = Wav::load(name); + if (pcm) { + delete pcm; + } +} + +void PCM::load(std::string const & name) +{ + load(name.c_str()); +} + +} -- cgit v1.2.3