From 5d07a3c1016a625dc1f44b54eac6dd4af7e60ea6 Mon Sep 17 00:00:00 2001 From: tylermurphy534 Date: Thu, 22 Sep 2022 11:29:32 -0400 Subject: add alut --- engine/xe_sound.cpp | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'engine/xe_sound.cpp') diff --git a/engine/xe_sound.cpp b/engine/xe_sound.cpp index fbb4628..d315179 100644 --- a/engine/xe_sound.cpp +++ b/engine/xe_sound.cpp @@ -8,33 +8,22 @@ namespace xe { XeSound::XeSound(const std::string& filename) { - ALvoid *data; - ALsizei size, freq; - ALenum format; - ALboolean loop; - char *bufferData; - - // alutLoadWAVFile(filename.c_str(), &format, &data, &size, &freq, &loop); - - // AudioFile file; - // file.load(filename); - - // std::vector data; - // file.writePCMToBuffer(data); - // auto getALSoundFormat = [](AudioFile& audioFile) { - // int bitDepth = audioFile.getBitDepth(); - // if (bitDepth == 16) - // return audioFile.isStereo() ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16; - // else if (bitDepth == 8) - // return audioFile.isStereo() ? AL_FORMAT_STEREO8 : AL_FORMAT_MONO8; - // else - // return -1; - // }; - - // alGenBuffers(1, &buffer); - // alBufferData(buffer, getALSoundFormat(file), data.data(), data.size(), file.getSampleRate()); + // ALvoid *data; + // ALsizei size, freq; + // ALenum format; + // ALboolean loop; + // char *bufferData; + + alutInit(0, NULL); + + std::cout << std::hex << alutGetError() << "\n"; + + buffer = alutCreateBufferFromFile(filename.c_str()); + + std::cout << std::hex << alutGetError() << "\n"; alGenSources(1, &source); + alSourcef(source, AL_GAIN, 1.f); alSourcef(source, AL_PITCH, 1.f); alSource3f(source, AL_POSITION, 0, 0, 0); @@ -47,6 +36,7 @@ XeSound::XeSound(const std::string& filename) { XeSound::~XeSound() { alDeleteSources(1, &source); alDeleteBuffers(1, &buffer); + alutExit(); } void XeSound::play() { -- cgit v1.2.3-freya