Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 9ec843e

Browse files
committed
Added proper handling for immobile sounds so they're audible with 3d sound
Added proper handling for music so it's audible with 3d sound
1 parent a21ee3c commit 9ec843e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Entities/SoundContainer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ namespace RTE {
138138

139139
for (std::vector<std::pair<ContentFile, FMOD::Sound * >>::const_iterator itr = m_Sounds.begin(); itr != m_Sounds.end() && result == FMOD_OK; ++itr) {
140140
FMOD_MODE soundMode = (m_Loops == 0) ? FMOD_LOOP_OFF : FMOD_LOOP_NORMAL;
141-
soundMode |= m_Immobile ? FMOD_3D_HEADRELATIVE : FMOD_3D_WORLDRELATIVE;
141+
if (m_Immobile) {
142+
soundMode |= FMOD_3D_HEADRELATIVE;
143+
m_AttenuationStartDistance = 100000;
144+
}
142145

143146
result = (result == FMOD_OK) ? itr->second->setMode(soundMode) : result;
144147
result = (result == FMOD_OK) ? itr->second->setLoopCount(m_Loops) : result;

Managers/AudioMan.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ namespace RTE {
267267

268268
FMOD::Sound *musicStream;
269269

270-
result = m_AudioSystem->createStream(filePath, FMOD_3D | FMOD_3D_HEADRELATIVE | ((loops == 0 || loops == 1) ? FMOD_LOOP_OFF : FMOD_LOOP_NORMAL), nullptr, &musicStream);
270+
result = m_AudioSystem->createStream(filePath, FMOD_3D_HEADRELATIVE | ((loops == 0 || loops == 1) ? FMOD_LOOP_OFF : FMOD_LOOP_NORMAL), nullptr, &musicStream);
271271
if (result != FMOD_OK) {
272272
g_ConsoleMan.PrintString("ERROR: Could not open music file " + std::string(filePath) + ": " + std::string(FMOD_ErrorString(result)));
273273
return;
@@ -279,9 +279,10 @@ namespace RTE {
279279
}
280280

281281
FMOD::Channel *musicChannel;
282-
result = m_AudioSystem->playSound(musicStream, m_MusicChannelGroup, true, &musicChannel);
282+
result = musicStream->set3DMinMaxDistance(100000, 100000);
283+
result = (result == FMOD_OK) ? m_AudioSystem->playSound(musicStream, m_MusicChannelGroup, true, &musicChannel) : result;
283284
if (result != FMOD_OK) {
284-
g_ConsoleMan.PrintString("ERROR: Could not play music file: " + std::string(filePath));
285+
g_ConsoleMan.PrintString("ERROR: Could not play music file: " + std::string(filePath) + ": " + std::string(FMOD_ErrorString(result)));
285286
return;
286287
}
287288
result = musicChannel->setPriority(PRIORITY_HIGH);

0 commit comments

Comments
 (0)