aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/Audio
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
committerLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
commit42aec6dac53dffa6afe072560a7e1d4986112538 (patch)
tree0836426857391df1b6a83f6368a183f83ec9b104 /Minecraft.Client/Common/Audio
parentc9d58eeac7c72f0b3038e084667b4d89a6249fce (diff)
parentef9b6fd500dfabd9463267b0dd9e29577eea8a2b (diff)
Merge branch 'main' into pr/win64-world-saves
# Conflicts: # Minecraft.Client/MinecraftServer.cpp # README.md
Diffstat (limited to 'Minecraft.Client/Common/Audio')
-rw-r--r--Minecraft.Client/Common/Audio/Consoles_SoundEngine.cpp39
-rw-r--r--Minecraft.Client/Common/Audio/Consoles_SoundEngine.h19
-rw-r--r--Minecraft.Client/Common/Audio/SoundEngine.cpp48
-rw-r--r--Minecraft.Client/Common/Audio/SoundNames.cpp72
4 files changed, 178 insertions, 0 deletions
diff --git a/Minecraft.Client/Common/Audio/Consoles_SoundEngine.cpp b/Minecraft.Client/Common/Audio/Consoles_SoundEngine.cpp
index 269b605b..e440316d 100644
--- a/Minecraft.Client/Common/Audio/Consoles_SoundEngine.cpp
+++ b/Minecraft.Client/Common/Audio/Consoles_SoundEngine.cpp
@@ -35,4 +35,43 @@ void ConsoleSoundEngine::SetIsPlayingNetherMusic(bool bVal)
m_bIsPlayingNetherMusic=bVal;
}
+void ConsoleSoundEngine::tick()
+{
+ if (scheduledSounds.empty())
+ {
+ return;
+ }
+
+ for(AUTO_VAR(it,scheduledSounds.begin()); it != scheduledSounds.end();)
+ {
+ SoundEngine::ScheduledSound *next = *it;
+ next->delay--;
+
+ if (next->delay <= 0)
+ {
+ play(next->iSound, next->x, next->y, next->z, next->volume, next->pitch);
+ it =scheduledSounds.erase(it);
+ delete next;
+ }
+ else
+ {
+ ++it;
+ }
+ }
+}
+void ConsoleSoundEngine::schedule(int iSound, float x, float y, float z, float volume, float pitch, int delayTicks)
+{
+ scheduledSounds.push_back(new SoundEngine::ScheduledSound(iSound, x, y, z, volume, pitch, delayTicks));
+}
+
+ConsoleSoundEngine::ScheduledSound::ScheduledSound(int iSound, float x, float y, float z, float volume, float pitch, int delay)
+{
+ this->iSound = iSound;
+ this->x = x;
+ this->y = y;
+ this->z = z;
+ this->volume = volume;
+ this->pitch = pitch;
+ this->delay = delay;
+} \ No newline at end of file
diff --git a/Minecraft.Client/Common/Audio/Consoles_SoundEngine.h b/Minecraft.Client/Common/Audio/Consoles_SoundEngine.h
index 4ec76036..b29b4378 100644
--- a/Minecraft.Client/Common/Audio/Consoles_SoundEngine.h
+++ b/Minecraft.Client/Common/Audio/Consoles_SoundEngine.h
@@ -69,6 +69,25 @@ public:
static const WCHAR *wchSoundNames[eSoundType_MAX];
static const WCHAR *wchUISoundNames[eSFX_MAX];
+public:
+ void tick();
+ void schedule(int iSound, float x, float y, float z, float volume, float pitch, int delayTicks);
+
+private:
+ class ScheduledSound
+ {
+ public:
+ int iSound;
+ float x, y, z;
+ float volume, pitch;
+ int delay;
+
+ public:
+ ScheduledSound(int iSound, float x, float y, float z, float volume, float pitch, int delay);
+ };
+
+ vector<ScheduledSound *> scheduledSounds;
+
private:
// platform specific functions
diff --git a/Minecraft.Client/Common/Audio/SoundEngine.cpp b/Minecraft.Client/Common/Audio/SoundEngine.cpp
index 1906b1aa..e9affe6b 100644
--- a/Minecraft.Client/Common/Audio/SoundEngine.cpp
+++ b/Minecraft.Client/Common/Audio/SoundEngine.cpp
@@ -490,6 +490,12 @@ void SoundEngine::updateMiles()
case eSoundType_MOB_ENDERDRAGON_HIT:
distanceScaler=100.0f;
break;
+ case eSoundType_FIREWORKS_BLAST:
+ case eSoundType_FIREWORKS_BLAST_FAR:
+ case eSoundType_FIREWORKS_LARGE_BLAST:
+ case eSoundType_FIREWORKS_LARGE_BLAST_FAR:
+ distanceScaler=100.0f;
+ break;
case eSoundType_MOB_GHAST_MOAN:
case eSoundType_MOB_GHAST_SCREAM:
case eSoundType_MOB_GHAST_DEATH:
@@ -624,6 +630,7 @@ static S32 running = AIL_ms_count();
void SoundEngine::tick(shared_ptr<Mob> *players, float a)
{
+ ConsoleSoundEngine::tick();
#ifdef __DISABLE_MILES__
return;
#endif
@@ -1129,6 +1136,11 @@ int SoundEngine::OpenStreamThreadProc( void* lpParameter )
#endif
SoundEngine *soundEngine = (SoundEngine *)lpParameter;
soundEngine->m_hStream = AIL_open_stream(soundEngine->m_hDriver,soundEngine->m_szStreamName,0);
+
+ if(soundEngine->m_hStream==0)
+ {
+ app.DebugPrintf("SoundEngine::OpenStreamThreadProc - Could not open - %s\n",soundEngine->m_szStreamName);
+ }
return 0;
}
@@ -1225,7 +1237,11 @@ void SoundEngine::playMusicUpdate()
char szName[255];
wcstombs(szName,wstrSoundName.c_str(),255);
+#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
+ string strFile="TPACK:/Data/" + string(szName) + ".binka";
+#else
string strFile="TPACK:\\Data\\" + string(szName) + ".binka";
+#endif
std::string mountedPath = StorageManager.GetMountedPath(strFile);
strcpy(m_szStreamName,mountedPath.c_str());
#endif
@@ -1318,6 +1334,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);
diff --git a/Minecraft.Client/Common/Audio/SoundNames.cpp b/Minecraft.Client/Common/Audio/SoundNames.cpp
index 170c87a0..1ab709b2 100644
--- a/Minecraft.Client/Common/Audio/SoundNames.cpp
+++ b/Minecraft.Client/Common/Audio/SoundNames.cpp
@@ -151,6 +151,78 @@ const WCHAR *ConsoleSoundEngine::wchSoundNames[eSoundType_MAX]=
L"dig.snow", // eSoundType_DIG_SNOW
L"dig.stone", // eSoundType_DIG_STONE
L"dig.wood", // eSoundType_DIG_WOOD
+
+ // 1.6.4
+ L"fireworks.launch", //eSoundType_FIREWORKS_LAUNCH,
+ L"fireworks.blast", //eSoundType_FIREWORKS_BLAST,
+ L"fireworks.blast_far", //eSoundType_FIREWORKS_BLAST_FAR,
+ L"fireworks.large_blast", //eSoundType_FIREWORKS_LARGE_BLAST,
+ L"fireworks.large_blast_far", //eSoundType_FIREWORKS_LARGE_BLAST_FAR,
+ L"fireworks.twinkle", //eSoundType_FIREWORKS_TWINKLE,
+ L"fireworks.twinkle_far", //eSoundType_FIREWORKS_TWINKLE_FAR,
+
+ L"mob.bat.idle", //eSoundType_MOB_BAT_IDLE,
+ L"mob.bat.hurt", //eSoundType_MOB_BAT_HURT,
+ L"mob.bat.death", //eSoundType_MOB_BAT_DEATH,
+ L"mob.bat.takeoff", //eSoundType_MOB_BAT_TAKEOFF,
+
+ L"mob.wither.spawn", //eSoundType_MOB_WITHER_SPAWN,
+ L"mob.wither.idle", //eSoundType_MOB_WITHER_IDLE,
+ L"mob.wither.hurt", //eSoundType_MOB_WITHER_HURT,
+ L"mob.wither.death", //eSoundType_MOB_WITHER_DEATH,
+ L"mob.wither.shoot", //eSoundType_MOB_WITHER_SHOOT,
+
+ L"mob.cow.step", //eSoundType_MOB_COW_STEP,
+ L"mob.chicken.step", //eSoundType_MOB_CHICKEN_STEP,
+ L"mob.pig.step", //eSoundType_MOB_PIG_STEP,
+ L"mob.enderman.stare", //eSoundType_MOB_ENDERMAN_STARE,
+ L"mob.enderman.scream", //eSoundType_MOB_ENDERMAN_SCREAM,
+ L"mob.sheep.shear", //eSoundType_MOB_SHEEP_SHEAR,
+ L"mob.sheep.step", //eSoundType_MOB_SHEEP_STEP,
+ L"mob.skeleton.death", //eSoundType_MOB_SKELETON_DEATH,
+ L"mob.skeleton.step", //eSoundType_MOB_SKELETON_STEP,
+ L"mob.spider.step", //eSoundType_MOB_SPIDER_STEP,
+ L"mob.wolf.step", //eSoundType_MOB_WOLF_STEP,
+ L"mob.zombie.step", //eSoundType_MOB_ZOMBIE_STEP,
+
+ L"liquid.swim", //eSoundType_LIQUID_SWIM,
+
+ L"mob.horse.land", //eSoundType_MOB_HORSE_LAND,
+ L"mob.horse.armor", //eSoundType_MOB_HORSE_ARMOR,
+ L"mob.horse.leather", //eSoundType_MOB_HORSE_LEATHER,
+ L"mob.horse.zombie.death", //eSoundType_MOB_HORSE_ZOMBIE_DEATH,
+ L"mob.horse.skeleton.death", //eSoundType_MOB_HORSE_SKELETON_DEATH,
+ L"mob.horse.donkey.death", //eSoundType_MOB_HORSE_DONKEY_DEATH,
+ L"mob.horse.death", //eSoundType_MOB_HORSE_DEATH,
+ L"mob.horse.zombie.hit", //eSoundType_MOB_HORSE_ZOMBIE_HIT,
+ L"mob.horse.skeleton.hit", //eSoundType_MOB_HORSE_SKELETON_HIT,
+ L"mob.horse.donkey.hit", //eSoundType_MOB_HORSE_DONKEY_HIT,
+ L"mob.horse.hit", //eSoundType_MOB_HORSE_HIT,
+ L"mob.horse.zombie.idle", //eSoundType_MOB_HORSE_ZOMBIE_IDLE,
+ L"mob.horse.skeleton.idle", //eSoundType_MOB_HORSE_SKELETON_IDLE,
+ L"mob.horse.donkey.idle", //eSoundType_MOB_HORSE_DONKEY_IDLE,
+ L"mob.horse.idle", //eSoundType_MOB_HORSE_IDLE,
+ L"mob.horse.donkey.angry", //eSoundType_MOB_HORSE_DONKEY_ANGRY,
+ L"mob.horse.angry", //eSoundType_MOB_HORSE_ANGRY,
+ L"mob.horse.gallop", //eSoundType_MOB_HORSE_GALLOP,
+ L"mob.horse.breathe", //eSoundType_MOB_HORSE_BREATHE,
+ L"mob.horse.wood", //eSoundType_MOB_HORSE_WOOD,
+ L"mob.horse.soft", //eSoundType_MOB_HORSE_SOFT,
+ L"mob.horse.jump", //eSoundType_MOB_HORSE_JUMP,
+
+ L"mob.witch.idle", //eSoundType_MOB_WITCH_IDLE, <--- missing
+ L"mob.witch.hurt", //eSoundType_MOB_WITCH_HURT, <--- missing
+ L"mob.witch.death", //eSoundType_MOB_WITCH_DEATH, <--- missing
+
+ L"mob.slime.big", //eSoundType_MOB_SLIME_BIG,
+ L"mob.slime.small", //eSoundType_MOB_SLIME_SMALL,
+
+ L"eating", //eSoundType_EATING <--- missing
+ L"random.levelup", //eSoundType_RANDOM_LEVELUP
+
+ // 4J-PB - Some sounds were updated, but we can't do that for the 360 or we have to do a new sound bank
+ // instead, we'll add the sounds as new ones and change the code to reference them
+ L"fire.new_ignite",
};