aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/Audio
diff options
context:
space:
mode:
authorGuglioIsStupid <bradsbluetab@gmail.com>2026-03-02 12:27:32 -0500
committerGitHub <noreply@github.com>2026-03-03 00:27:32 +0700
commit852b9aac50ea1771b4cca6985a35a3e812e6cbdc (patch)
tree5bf0baf783d5d921a7f4d845c34f7cf09612bcb5 /Minecraft.Client/Common/Audio
parentfe65211d42f7c94df6a7fe69b385d2c6ad2876c7 (diff)
Allow for loading of WAVE Audio files (#148)
* Allow for loading of WAVE Audio files * Remove usage of strcpy and use _s versions of file opening * Update SoundEngine.cpp --------- Co-authored-by: void_17 <61356189+void2012@users.noreply.github.com>
Diffstat (limited to 'Minecraft.Client/Common/Audio')
-rw-r--r--Minecraft.Client/Common/Audio/SoundEngine.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/Minecraft.Client/Common/Audio/SoundEngine.cpp b/Minecraft.Client/Common/Audio/SoundEngine.cpp
index 43d2059d..dfed0de7 100644
--- a/Minecraft.Client/Common/Audio/SoundEngine.cpp
+++ b/Minecraft.Client/Common/Audio/SoundEngine.cpp
@@ -1318,6 +1318,38 @@ void SoundEngine::playMusicUpdate()
// char *SoundName = (char *)ConvertSoundPathToName(name);
// strcat((char *)szStreamName,SoundName);
+ const bool isCD = (m_musicID >= m_iStream_CD_1);
+ const char* folder = isCD ? "cds/" : "music/";
+
+ FILE* pFile = nullptr;
+ if (fopen_s(&pFile, reinterpret_cast<char*>(m_szStreamName), "rb") == 0 && pFile)
+ {
+ fclose(pFile);
+ }
+ else
+ {
+ const char* extensions[] = { ".wav" }; // only wav works outside of binka files to my knowledge, i've only tested ogg, wav, mp3 and only wav worked out of the bunch
+ size_t count = sizeof(extensions) / sizeof(extensions[0]);
+ bool found = false;
+
+ for (size_t i = 0; i < count; i++)
+ {
+ int n = sprintf_s(reinterpret_cast<char*>(m_szStreamName), 512, "%s%s%s%s", m_szMusicPath, folder, m_szStreamFileA[m_musicID], extensions[i]);
+ if (n < 0) continue;
+
+ if (fopen_s(&pFile, reinterpret_cast<char*>(m_szStreamName), "rb") == 0 && pFile)
+ {
+ fclose(pFile);
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ return;
+ }
+ }
app.DebugPrintf("Starting streaming - %s\n",m_szStreamName);