|
2 | 2 | #include "ConsoleMan.h"
|
3 | 3 | #include "SettingsMan.h"
|
4 | 4 | #include "SceneMan.h"
|
| 5 | +#include "ActivityMan.h" |
5 | 6 | #include "SoundContainer.h"
|
6 | 7 | #include "GUISound.h"
|
7 | 8 |
|
@@ -73,12 +74,35 @@ namespace RTE {
|
73 | 74 | void AudioMan::Update() {
|
74 | 75 | if (m_AudioEnabled) {
|
75 | 76 |
|
76 |
| - //TODO handle splitscreen - do m_AudioSystem->set3DNumListeners(numPlayers); and set each player's position |
77 |
| - //TODO allow setting vel for AEmitter and PEmitter |
78 |
| - m_AudioSystem->set3DListenerAttributes(0, &GetAsFMODVector(g_SceneMan.GetScrollTarget()), NULL, &c_FMODForward, &c_FMODUp); |
79 |
| - m_AudioSystem->update(); |
| 77 | + //TODO allow setting vel for AEmitter and PEmitter. Also maybe consider setting vel on listener when sceneman target scrolling is happening. |
| 78 | + |
| 79 | + FMOD_RESULT status = FMOD_OK; |
| 80 | + |
| 81 | + if (g_ActivityMan.ActivityRunning()) { |
| 82 | + Activity const *currentActivity = g_ActivityMan.GetActivity(); |
| 83 | + |
| 84 | + if (m_CurrentActivityHumanCount != (m_IsInMultiplayerMode ? 1 : currentActivity->GetHumanCount())) { |
| 85 | + m_CurrentActivityHumanCount = m_IsInMultiplayerMode ? 1 : currentActivity->GetHumanCount(); |
| 86 | + status = m_AudioSystem->set3DNumListeners(m_CurrentActivityHumanCount); |
| 87 | + } |
| 88 | + |
| 89 | + int audioSystemPlayerNumber = 0; |
| 90 | + for (int player = 0; player < currentActivity->GetPlayerCount() && audioSystemPlayerNumber < m_CurrentActivityHumanCount; player++) { |
| 91 | + if (currentActivity->PlayerHuman(player)) { |
| 92 | + status = m_AudioSystem->set3DListenerAttributes(audioSystemPlayerNumber, &GetAsFMODVector(g_SceneMan.GetScrollTarget(currentActivity->ScreenOfPlayer(player))), NULL, &c_FMODForward, &c_FMODUp); |
| 93 | + audioSystemPlayerNumber++; |
| 94 | + } |
| 95 | + } |
| 96 | + } else { |
| 97 | + if (m_CurrentActivityHumanCount != 1) { |
| 98 | + m_CurrentActivityHumanCount = 1; |
| 99 | + status = m_AudioSystem->set3DNumListeners(1); |
| 100 | + } |
| 101 | + status = m_AudioSystem->set3DListenerAttributes(0, &GetAsFMODVector(g_SceneMan.GetScrollTarget()), NULL, &c_FMODForward, &c_FMODUp); |
| 102 | + } |
| 103 | + |
| 104 | + status = m_AudioSystem->update(); |
80 | 105 |
|
81 |
| - // Done waiting for silence |
82 | 106 | if (!IsMusicPlaying() && m_SilenceTimer.IsPastRealTimeLimit()) { PlayNextStream(); }
|
83 | 107 | }
|
84 | 108 | }
|
|
0 commit comments