From 55be6447e33e27cc8820b3fa7d6a8decd147cd2e Mon Sep 17 00:00:00 2001 From: GuglioIsStupid Date: Fri, 6 Mar 2026 19:38:14 -0500 Subject: Sound Fixes (#686) * Fix sound settings not applying * Reimplement miles sound artifacts * Fix stone brick stairs recipe * Fix craft and scroll sound * Rename scrollfocus.ogg to scroll.ogg * Remove unneeded code * Reorganize sounds, revert spam sound press, add witch sounds and fix slimes * I forgot my console again --- Minecraft.Client/Common/Audio/SoundEngine.cpp | 105 +++++++++++++------------- 1 file changed, 51 insertions(+), 54 deletions(-) (limited to 'Minecraft.Client/Common/Audio/SoundEngine.cpp') diff --git a/Minecraft.Client/Common/Audio/SoundEngine.cpp b/Minecraft.Client/Common/Audio/SoundEngine.cpp index b2ca2be3..12fa03b4 100644 --- a/Minecraft.Client/Common/Audio/SoundEngine.cpp +++ b/Minecraft.Client/Common/Audio/SoundEngine.cpp @@ -187,7 +187,7 @@ void SoundEngine::init(Options* pOptions) m_bSystemMusicPlaying = false; app.DebugPrintf("---miniaudio initialized\n"); - + return; } @@ -265,7 +265,6 @@ void SoundEngine::updateMiniAudio() finalVolume = 1.0f; ma_sound_set_volume(&s->sound, finalVolume); - ma_sound_set_pitch(&s->sound, s->info.pitch); if (s->info.bIs3D) @@ -471,67 +470,64 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume, floa char finalPath[256]; sprintf_s(finalPath, "%s.wav", basePath); - if (!FileExists(finalPath)) - { - int count = 0; - - for (size_t i = 1; i < 32; i++) - { - char numberedFolder[256]; - sprintf_s(numberedFolder, "%s%d", basePath, i); - - DWORD attr = GetFileAttributesA(numberedFolder); - - if (attr != INVALID_FILE_ATTRIBUTES && - (attr & FILE_ATTRIBUTE_DIRECTORY)) - { - count++; - } - else - { - break; - } - } - - char chosenFolder[256]; - - if (count == 0) - { - sprintf_s(chosenFolder, "%s", basePath); - } - else - { - int chosen = (rand() % count) + 1; - sprintf_s(chosenFolder, "%s%d", basePath, chosen); - } + const char* extensions[] = { ".ogg", ".wav", ".mp3" }; + size_t extCount = sizeof(extensions) / sizeof(extensions[0]); + bool found = false; - char searchPattern[256]; - sprintf_s(searchPattern, "%s\\*.wav", chosenFolder); + for (size_t extIdx = 0; extIdx < extCount; extIdx++) + { + char basePlusExt[256]; + sprintf_s(basePlusExt, "%s%s", basePath, extensions[extIdx]); + + DWORD attr = GetFileAttributesA(basePlusExt); + if (attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY)) + { + sprintf_s(finalPath, "%s", basePlusExt); + found = true; + break; + } + } - WIN32_FIND_DATAA findData; - HANDLE hFind = FindFirstFileA(searchPattern, &findData); + if (!found) + { + int count = 0; - const char* extensions[] = { ".ogg", ".wav", ".mp3" }; - size_t extCount = sizeof(extensions) / sizeof(extensions[0]); - bool found = false; - for (size_t i = 0; i < extCount; i++) + for (size_t extIdx = 0; extIdx < extCount; extIdx++) { - sprintf_s(searchPattern, "%s\\*%s", chosenFolder, extensions[i]); - hFind = FindFirstFileA(searchPattern, &findData); - if (hFind != INVALID_HANDLE_VALUE) + for (size_t i = 1; i < 32; i++) { - found = true; - break; + char numberedPath[256]; + sprintf_s(numberedPath, "%s%d%s", basePath, i, extensions[extIdx]); + + DWORD attr = GetFileAttributesA(numberedPath); + if (attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY)) + { + count = i; + } } } - if (hFind == INVALID_HANDLE_VALUE) + + if (count > 0) { - app.DebugPrintf("No sound files found in %s\n", chosenFolder); - return; + int chosen = (rand() % count) + 1; + for (size_t extIdx = 0; extIdx < extCount; extIdx++) + { + char numberedPath[256]; + sprintf_s(numberedPath, "%s%d%s", basePath, chosen, extensions[extIdx]); + + DWORD attr = GetFileAttributesA(numberedPath); + if (attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY)) + { + sprintf_s(finalPath, "%s", numberedPath); + found = true; + break; + } + } + if (!found) + { + sprintf_s(finalPath, "%s%d.wav", basePath, chosen); + } } - - sprintf_s(finalPath, "%s\\%s", chosenFolder, findData.cFileName); - FindClose(hFind); } MiniAudioSound* s = new MiniAudioSound(); @@ -649,6 +645,7 @@ void SoundEngine::playUI(int iSound, float volume, float pitch) float finalVolume = volume * m_MasterEffectsVolume; if (finalVolume > 1.0f) finalVolume = 1.0f; + printf("UI Sound volume set to %f\nEffects volume: %f\n", finalVolume, m_MasterEffectsVolume); ma_sound_set_volume(&s->sound, finalVolume); ma_sound_set_pitch(&s->sound, pitch); -- cgit v1.2.3