From cc3310b556086afbcbad5cb1dc4f5129a302a264 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sat, 5 Aug 2023 03:55:30 -0400 Subject: [PATCH] Fix Loading Stereo Sound Data --- platforms/sdl/SoundSystemAL.cpp | 2 +- tools/grabsounds.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/platforms/sdl/SoundSystemAL.cpp b/platforms/sdl/SoundSystemAL.cpp index 6783590..23567f1 100644 --- a/platforms/sdl/SoundSystemAL.cpp +++ b/platforms/sdl/SoundSystemAL.cpp @@ -117,7 +117,7 @@ ALuint SoundSystemAL::get_buffer(const SoundDesc &sound) { } // Sound Data Size - int size = sound.m_header.m_length * sound.m_header.m_bytes_per_sample; + int size = sound.m_header.m_channels * sound.m_header.m_length * sound.m_header.m_bytes_per_sample; // Create Buffer ALuint buffer; diff --git a/tools/grabsounds.py b/tools/grabsounds.py index 42a140b..6cbd222 100644 --- a/tools/grabsounds.py +++ b/tools/grabsounds.py @@ -108,16 +108,19 @@ def main(): include_all_str += '#include "' + item[0] + '.h"\n' ostr = header_1 + header_2 + channels = read_int_from_bytes(bytes, item[1] + 0) data_length = read_int_from_bytes(bytes, item[1] + 12) # @NOTE: All the PCM sound data is in `.data`. So there's no consts to be found. ostr += 'PCMSoundHeader '+item[0]+' =\n{\n' - ostr += '\t' + str(read_int_from_bytes(bytes, item[1] + 0)) + ',\n' + ostr += '\t' + str(channels) + ',\n' ostr += '\t' + str(read_int_from_bytes(bytes, item[1] + 4)) + ',\n' ostr += '\t' + str(read_int_from_bytes(bytes, item[1] + 8)) + ',\n' ostr += '\t' + str(data_length) ostr += '\n};\n\n' + + data_length *= channels ostr += 'uint16_t '+item[0]+'_data['+str(data_length)+'] =\n{'