|
|
@@ -26,12 +26,12 @@ cMusicManager::cMusicManager() |
|
|
m_bIsInitialised = false; |
|
|
m_bDisabled = false; |
|
|
m_nMusicMode = MUSICMODE_DISABLED; |
|
|
m_nCurrentStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nPreviousStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nCurrentStreamedSound = NO_TRACK; |
|
|
m_nPreviousStreamedSound = NO_TRACK; |
|
|
m_bFrontendTrackFinished = false; |
|
|
m_bPlayInFrontend = false; |
|
|
m_bSetNextStation = false; |
|
|
m_nAnnouncement = NO_STREAMED_SOUND; |
|
|
m_nAnnouncement = NO_TRACK; |
|
|
m_bPreviousPlayerInCar = false; |
|
|
m_bPlayerInCar = false; |
|
|
m_bAnnouncementInProgress = false; |
|
|
@@ -224,7 +224,7 @@ cMusicManager::Initialise() |
|
|
m_bRadioSetByScript = false; |
|
|
m_nRadioStation = HEAD_RADIO; |
|
|
m_nRadioPosition = -1; |
|
|
m_nRadioInCar = NO_STREAMED_SOUND; |
|
|
m_nRadioInCar = NO_TRACK; |
|
|
gNumRetunePresses = 0; |
|
|
gRetuneCounter = 0; |
|
|
m_bIsInitialised = true; |
|
|
@@ -239,8 +239,8 @@ cMusicManager::Terminate() |
|
|
|
|
|
if (SampleManager.IsStreamPlaying(0)) { |
|
|
SampleManager.StopStreamedFile(0); |
|
|
m_nCurrentStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nPreviousStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nCurrentStreamedSound = NO_TRACK; |
|
|
m_nPreviousStreamedSound = NO_TRACK; |
|
|
} |
|
|
m_bIsInitialised = false; |
|
|
} |
|
|
@@ -274,8 +274,8 @@ cMusicManager::ChangeMusicMode(uint8 mode) |
|
|
} |
|
|
SampleManager.StopStreamedFile(0); |
|
|
} |
|
|
m_nCurrentStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nPreviousStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nCurrentStreamedSound = NO_TRACK; |
|
|
m_nPreviousStreamedSound = NO_TRACK; |
|
|
m_bFrontendTrackFinished = false; |
|
|
m_bPlayInFrontend = false; |
|
|
m_bSetNextStation = false; |
|
|
@@ -301,14 +301,14 @@ cMusicManager::GetRadioInCar(void) |
|
|
CVehicle *veh = FindPlayerVehicle(); |
|
|
if (veh != nil){ |
|
|
if (UsesPoliceRadio(veh)) { |
|
|
if (m_nRadioInCar == NO_STREAMED_SOUND || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) |
|
|
if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) |
|
|
return POLICE_RADIO; |
|
|
return m_nRadioInCar; |
|
|
} else return veh->m_nRadioStation; |
|
|
} |
|
|
} |
|
|
|
|
|
if (m_nRadioInCar == NO_STREAMED_SOUND || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) |
|
|
if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) |
|
|
return RADIO_OFF; |
|
|
return m_nRadioInCar; |
|
|
} |
|
|
@@ -347,7 +347,7 @@ cMusicManager::ResetMusicAfterReload() |
|
|
m_bRadioSetByScript = false; |
|
|
m_nRadioStation = 0; |
|
|
m_nRadioPosition = -1; |
|
|
m_nAnnouncement = NO_STREAMED_SOUND; |
|
|
m_nAnnouncement = NO_TRACK; |
|
|
m_bAnnouncementInProgress = false; |
|
|
m_bSetNextStation = false; |
|
|
gRetuneCounter = 0; |
|
|
@@ -384,7 +384,7 @@ cMusicManager::Service() |
|
|
m_nLastTrackServiceTime = m_nTimer; |
|
|
} else m_bDoTrackService = false; |
|
|
|
|
|
if (m_nCurrentStreamedSound == NO_STREAMED_SOUND && SampleManager.IsStreamPlaying(0)) |
|
|
if (m_nCurrentStreamedSound == NO_TRACK && SampleManager.IsStreamPlaying(0)) |
|
|
SampleManager.StopStreamedFile(0); |
|
|
else switch (m_nMusicMode) { |
|
|
case MUSICMODE_FRONTEND: ServiceFrontEndMode(); break; |
|
|
@@ -410,8 +410,8 @@ cMusicManager::ServiceFrontEndMode() |
|
|
default: |
|
|
break; |
|
|
} |
|
|
m_nCurrentStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nPreviousStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nCurrentStreamedSound = NO_TRACK; |
|
|
m_nPreviousStreamedSound = NO_TRACK; |
|
|
} |
|
|
} else if (bHasStarted) { |
|
|
if (!SampleManager.IsStreamPlaying(0)) |
|
|
@@ -434,6 +434,7 @@ cMusicManager::ServiceGameMode() |
|
|
{ |
|
|
bool bRadioOff = false; |
|
|
static int8 nFramesSinceCutsceneEnded = -1; |
|
|
uint8 volume; |
|
|
|
|
|
m_bPreviousPlayerInCar = m_bPlayerInCar; |
|
|
m_bPlayerInCar = PlayerInCar(); |
|
|
@@ -516,56 +517,54 @@ cMusicManager::ServiceGameMode() |
|
|
m_bPlayerInCar = false; |
|
|
if (FindPlayerVehicle()) |
|
|
FindPlayerVehicle()->m_nRadioStation = m_nCurrentStreamedSound; |
|
|
m_nCurrentStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nCurrentStreamedSound = NO_TRACK; |
|
|
} |
|
|
if (CTimer::GetIsSlowMotionActive()) { |
|
|
if (TheCamera.pTargetEntity != nil) { |
|
|
float dist = (TheCamera.pTargetEntity->GetPosition() - TheCamera.GetPosition()).MagnitudeSqr(); |
|
|
if (dist >= 3025.0f) { |
|
|
float DistToTargetSq = (TheCamera.pTargetEntity->GetPosition() - TheCamera.GetPosition()).MagnitudeSqr(); |
|
|
if (DistToTargetSq >= SQR(55.0f)) { |
|
|
SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); |
|
|
} else if (dist >= 100.0f) { |
|
|
int8 volume = ((45.0f - (Sqrt(dist) - 10.0f)) / 45.0f * 100.0f); |
|
|
int8 pan; |
|
|
if (AudioManager.IsMissionAudioSamplePlaying()) |
|
|
} else if (DistToTargetSq >= SQR(10.0f)) { |
|
|
volume = ((45.0f - (Sqrt(DistToTargetSq) - 10.0f)) / 45.0f * 100.0f); |
|
|
uint8 pan; |
|
|
if (AudioManager.ShouldDuckMissionAudio()) |
|
|
volume /= 4; |
|
|
if (volume != 0) { |
|
|
CVector trVec; |
|
|
AudioManager.TranslateEntity(&TheCamera.pTargetEntity->GetPosition(), &trVec); |
|
|
pan = AudioManager.ComputePan(55.0f, &trVec); |
|
|
if (volume > 0) { |
|
|
CVector panVec; |
|
|
AudioManager.TranslateEntity(&TheCamera.pTargetEntity->GetPosition(), &panVec); |
|
|
pan = AudioManager.ComputePan(55.0f, &panVec); |
|
|
} else { |
|
|
pan = 0; |
|
|
} |
|
|
if (gRetuneCounter) |
|
|
volume /= 4; |
|
|
SampleManager.SetStreamedVolumeAndPan(volume, pan, 0, 0); |
|
|
} else if (AudioManager.IsMissionAudioSamplePlaying()) { |
|
|
} else if (AudioManager.ShouldDuckMissionAudio()) { |
|
|
SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0); |
|
|
} else if (gRetuneCounter) { |
|
|
SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0); |
|
|
} else { |
|
|
SampleManager.SetStreamedVolumeAndPan(100, 63, 0, 0); |
|
|
} |
|
|
} |
|
|
} else if (AudioManager.IsMissionAudioSamplePlaying()) { |
|
|
} else if (AudioManager.ShouldDuckMissionAudio()) { |
|
|
SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0); |
|
|
nFramesSinceCutsceneEnded = 0; |
|
|
} else { |
|
|
int8 volume; |
|
|
if (nFramesSinceCutsceneEnded == -1) { |
|
|
volume = 100; |
|
|
} else if (nFramesSinceCutsceneEnded >= 20) { |
|
|
if (nFramesSinceCutsceneEnded >= 40) { |
|
|
nFramesSinceCutsceneEnded = -1; |
|
|
volume = 100; |
|
|
} else { |
|
|
volume = 3 * (nFramesSinceCutsceneEnded - 20) + 25; |
|
|
nFramesSinceCutsceneEnded++; |
|
|
} |
|
|
} else { |
|
|
} else if (nFramesSinceCutsceneEnded < 20) { |
|
|
nFramesSinceCutsceneEnded++; |
|
|
volume = 25; |
|
|
} else if (nFramesSinceCutsceneEnded < 40) { |
|
|
volume = 3 * (nFramesSinceCutsceneEnded - 20) + 25; |
|
|
nFramesSinceCutsceneEnded++; |
|
|
} else { |
|
|
nFramesSinceCutsceneEnded = -1; |
|
|
volume = 100; |
|
|
} |
|
|
if (gRetuneCounter) volume /= 4; |
|
|
if (gRetuneCounter != 0) |
|
|
volume /= 4; |
|
|
SampleManager.SetStreamedVolumeAndPan(volume, 63, 0, 0); |
|
|
} |
|
|
return; |
|
|
@@ -585,7 +584,7 @@ cMusicManager::ServiceGameMode() |
|
|
} else { |
|
|
m_nCurrentStreamedSound = m_nRadioStation; |
|
|
if (FindPlayerVehicle()->m_nRadioStation == m_nCurrentStreamedSound) { |
|
|
m_nPreviousStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nPreviousStreamedSound = NO_TRACK; |
|
|
SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); |
|
|
SampleManager.StopStreamedFile(0); |
|
|
} |
|
|
@@ -608,19 +607,19 @@ cMusicManager::ServiceGameMode() |
|
|
} |
|
|
} else { |
|
|
m_bPlayerInCar = false; |
|
|
m_nCurrentStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nCurrentStreamedSound = NO_TRACK; |
|
|
} |
|
|
} |
|
|
|
|
|
void |
|
|
cMusicManager::StopFrontEndTrack() |
|
|
{ |
|
|
if (IsInitialised() && !m_bDisabled && m_nMusicMode == MUSICMODE_FRONTEND && m_nCurrentStreamedSound != NO_STREAMED_SOUND) { |
|
|
if (IsInitialised() && !m_bDisabled && m_nMusicMode == MUSICMODE_FRONTEND && m_nCurrentStreamedSound != NO_TRACK) { |
|
|
m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); |
|
|
m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); |
|
|
SampleManager.StopStreamedFile(0); |
|
|
m_nPreviousStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nCurrentStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nPreviousStreamedSound = NO_TRACK; |
|
|
m_nCurrentStreamedSound = NO_TRACK; |
|
|
} |
|
|
} |
|
|
|
|
|
@@ -636,17 +635,17 @@ cMusicManager::PlayFrontEndTrack(uint8 track, uint8 bPlayInFrontend) |
|
|
{ |
|
|
if (IsInitialised() && !m_bDisabled && track < TOTAL_STREAMED_SOUNDS) { |
|
|
if (m_nMusicMode == MUSICMODE_GAME) { |
|
|
if (m_nCurrentStreamedSound != NO_STREAMED_SOUND) { |
|
|
if (m_nCurrentStreamedSound != NO_TRACK) { |
|
|
if (m_bAnnouncementInProgress) { |
|
|
m_nAnnouncement = NO_STREAMED_SOUND; |
|
|
m_nAnnouncement = NO_TRACK; |
|
|
m_bAnnouncementInProgress = false; |
|
|
} |
|
|
m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); |
|
|
m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); |
|
|
} |
|
|
SampleManager.StopStreamedFile(0); |
|
|
} else if (m_nMusicMode == MUSICMODE_FRONTEND) { |
|
|
if (m_nCurrentStreamedSound != NO_STREAMED_SOUND) { |
|
|
if (m_nCurrentStreamedSound != NO_TRACK) { |
|
|
m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); |
|
|
m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); |
|
|
} |
|
|
@@ -691,23 +690,22 @@ cMusicManager::StopCutSceneMusic(void) |
|
|
{ |
|
|
if (IsInitialised() && !m_bDisabled && m_nMusicMode == MUSICMODE_CUTSCENE) { |
|
|
SampleManager.StopStreamedFile(0); |
|
|
m_nCurrentStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nCurrentStreamedSound = NO_TRACK; |
|
|
} |
|
|
} |
|
|
|
|
|
uint32 |
|
|
cMusicManager::GetTrackStartPos(uint8 track) |
|
|
{ |
|
|
uint32 result; |
|
|
uint32 timer = m_aTracks[track].m_nLastPosCheckTimer; |
|
|
if (CTimer::GetTimeInMillisecondsPauseMode() <= timer) { |
|
|
result = m_aTracks[track].m_nPosition; |
|
|
uint32 pos = m_aTracks[track].m_nPosition; |
|
|
if (CTimer::GetTimeInMillisecondsPauseMode() > m_aTracks[track].m_nLastPosCheckTimer) |
|
|
pos += Min(CTimer::GetTimeInMillisecondsPauseMode() - m_aTracks[track].m_nLastPosCheckTimer, 90000); |
|
|
else |
|
|
m_aTracks[track].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); |
|
|
} else |
|
|
result = Min(CTimer::GetTimeInMillisecondsPauseMode() - timer, 90000) + m_aTracks[track].m_nPosition; |
|
|
|
|
|
if (result > m_aTracks[track].m_nLength) result %= m_aTracks[track].m_nLength; |
|
|
return result; |
|
|
if (pos > m_aTracks[track].m_nLength) |
|
|
pos %= m_aTracks[track].m_nLength; |
|
|
return pos; |
|
|
} |
|
|
|
|
|
|
|
|
@@ -733,21 +731,21 @@ cMusicManager::ServiceAmbience() |
|
|
uint8 volume; |
|
|
|
|
|
if (m_bAnnouncementInProgress) { |
|
|
m_nAnnouncement = NO_STREAMED_SOUND; |
|
|
m_nAnnouncement = NO_TRACK; |
|
|
m_bAnnouncementInProgress = false; |
|
|
} |
|
|
if (m_nCurrentStreamedSound < STREAMED_SOUND_CITY_AMBIENT) { |
|
|
if (SampleManager.IsStreamPlaying(0)) { |
|
|
m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); |
|
|
m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); |
|
|
SampleManager.StopStreamedFile(0); |
|
|
m_nCurrentStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nCurrentStreamedSound = NO_TRACK; |
|
|
return; |
|
|
} |
|
|
m_nCurrentStreamedSound = STREAMED_SOUND_CITY_AMBIENT; |
|
|
} |
|
|
if (CWorld::Players[CWorld::PlayerInFocus].m_WBState != WBSTATE_PLAYING && !SampleManager.IsStreamPlaying(0)) { |
|
|
m_nCurrentStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nCurrentStreamedSound = NO_TRACK; |
|
|
return; |
|
|
} |
|
|
|
|
|
@@ -774,7 +772,7 @@ cMusicManager::ServiceAmbience() |
|
|
SampleManager.SetStreamedVolumeAndPan(volume, 63, 1, 0); |
|
|
m_bDontServiceAmbienceTrack = true; |
|
|
} else |
|
|
m_nCurrentStreamedSound = NO_STREAMED_SOUND; |
|
|
m_nCurrentStreamedSound = NO_TRACK; |
|
|
} |
|
|
} |
|
|
|
|
|
@@ -813,7 +811,7 @@ cMusicManager::ServiceAnnouncement() |
|
|
static int8 cCheck = 0; |
|
|
if (m_bAnnouncementInProgress) { |
|
|
if (!SampleManager.IsStreamPlaying(0)) { |
|
|
m_nAnnouncement = NO_STREAMED_SOUND; |
|
|
m_nAnnouncement = NO_TRACK; |
|
|
m_bAnnouncementInProgress = false; |
|
|
} |
|
|
return true; |
|
|
@@ -823,7 +821,7 @@ cMusicManager::ServiceAnnouncement() |
|
|
cCheck = 0; |
|
|
int pos = SampleManager.GetStreamedFilePosition(0); |
|
|
if (SampleManager.IsStreamPlaying(0)) { |
|
|
if (m_nCurrentStreamedSound != NO_STREAMED_SOUND) { |
|
|
if (m_nCurrentStreamedSound != NO_TRACK) { |
|
|
m_aTracks[m_nCurrentStreamedSound].m_nPosition = pos; |
|
|
m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); |
|
|
SampleManager.StopStreamedFile(0); |
|
|
@@ -832,7 +830,7 @@ cMusicManager::ServiceAnnouncement() |
|
|
|
|
|
SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); |
|
|
if (SampleManager.StartStreamedFile(m_nAnnouncement, 0, 0)) { |
|
|
SampleManager.SetStreamedVolumeAndPan(AudioManager.IsMissionAudioSamplePlaying() ? 25 : 100, 63, 0, 0); |
|
|
SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, 0, 0); |
|
|
m_bAnnouncementInProgress = true; |
|
|
m_nPreviousStreamedSound = m_nCurrentStreamedSound; |
|
|
m_nCurrentStreamedSound = m_nAnnouncement; |
|
|
@@ -905,7 +903,7 @@ cMusicManager::ChangeRadioChannel() |
|
|
return false; |
|
|
if (!SampleManager.StartStreamedFile(m_nCurrentStreamedSound, GetTrackStartPos(m_nCurrentStreamedSound), 0)) |
|
|
return false; |
|
|
SampleManager.SetStreamedVolumeAndPan(AudioManager.IsMissionAudioSamplePlaying() ? 25 : 100, 63, 0, 0); |
|
|
SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, 0, 0); |
|
|
} |
|
|
return true; |
|
|
} |