From d54e98200f9552f8cf39da2a2669617de6d77e99 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 18 Mar 2023 15:59:17 -0700 Subject: [PATCH] Fix loading sounds with non-16 bit depths This fixes an issue where sound effects of bit depths that weren't 16, such as 8, were being played incorrectly, as described in #886. The problem is that when loading the sound effect, we would always set the bit depth to 16 no matter what! Instead, we should set the bit depth to the actual bit depth of the file. Fixes #886. --- desktop_version/src/Music.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index e963db22..f4231ca7 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -116,7 +116,7 @@ public: format.nChannels = spec.channels; format.nSamplesPerSec = spec.freq; format.wFormatTag = FAUDIO_FORMAT_PCM; - format.wBitsPerSample = 16; + format.wBitsPerSample = SDL_AUDIO_BITSIZE(spec.format); format.nBlockAlign = format.nChannels * format.wBitsPerSample; format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; format.cbSize = 0;