diff options
Diffstat (limited to 'src/audio/AudioManager.cpp')
-rw-r--r-- | src/audio/AudioManager.cpp | 93 |
1 files changed, 64 insertions, 29 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 51f1946f..4a47c739 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -15,7 +15,7 @@ cAudioManager AudioManager; #define SPEED_OF_SOUND 343.f -#define TIME_SPENT 40 +#define TIME_SPENT 30 cAudioManager::cAudioManager() { @@ -340,6 +340,8 @@ cAudioManager::ResetTimers(uint32 time) ClearMissionAudio(0); ClearMissionAudio(1); SampleManager.StopChannel(CHANNEL_POLICE_RADIO); + SampleManager.StopChannel(CHANNEL_MISSION_AUDIO_1); + SampleManager.StopChannel(CHANNEL_MISSION_AUDIO_2); SampleManager.SetEffectsFadeVolume(0); SampleManager.SetMusicFadeVolume(0); MusicManager.ResetMusicAfterReload(); @@ -533,27 +535,17 @@ cAudioManager::ServiceSoundEffects() #endif m_bReduceReleasingPriority = (m_FrameCounter++ % 5) == 0; if (m_bIsPaused && !m_bWasPaused) { -#ifdef GTA_PS2 - if (m_bIsSurround) { - for (uint32 i = 0; i < NUM_CHANNELS_DTS_GENERIC; i++) - SampleManager.StopChannel(i); - - SampleManager.SetChannelFrequency(CHANNEL_DTS_POLICE_RADIO, 0); - SampleManager.SetChannelFrequency(CHANNEL_DTS_MISSION_AUDIO_1, 0); - SampleManager.SetChannelFrequency(CHANNEL_DTS_MISSION_AUDIO_2, 0); - SampleManager.SetChannelFrequency(CHANNEL_DTS_PLAYER_VEHICLE_ENGINE, 0); - } else { - for (uint32 i = 0; i < NUM_CHANNELS_GENERIC; i++) - SampleManager.StopChannel(i); - - SampleManager.SetChannelFrequency(CHANNEL_POLICE_RADIO, 0); - SampleManager.SetChannelFrequency(CHANNEL_MISSION_AUDIO_1, 0); - SampleManager.SetChannelFrequency(CHANNEL_MISSION_AUDIO_2, 0); - SampleManager.SetChannelFrequency(CHANNEL_PLAYER_VEHICLE_ENGINE, 0); - } -#else - for (uint32 i = 0; i < NUM_CHANNELS; i++) + for (uint32 i = 0; i < NUM_CHANNELS_GENERIC; i++) SampleManager.StopChannel(i); + SampleManager.SetChannelFrequency(CHANNEL_POLICE_RADIO, 0); + SampleManager.SetChannelFrequency(CHANNEL_MISSION_AUDIO_1, 0); + SampleManager.SetChannelFrequency(CHANNEL_MISSION_AUDIO_2, 0); + SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE); +#if defined(GTA_PS2) || defined(GTA_PSP) + // PSP and PS2 just stop the sound, mobile doesn't. Let's not have it on PC either + uint8 missionAudioChannel = m_bIsSurround ? CHANNEL_DTS_MISSION_AUDIO_1 : CHANNEL_MISSION_AUDIO_1; + SampleManager.StopChannel(missionAudioChannel); + SampleManager.StopChannel(missionAudioChannel+1); #endif ClearRequestedQueue(); if (m_nActiveQueue) { @@ -574,11 +566,14 @@ cAudioManager::ServiceSoundEffects() ProcessSpecial(); ClearRequestedQueue(); InterrogateAudioEntities(); - m_sPedComments.Process(); - ServicePoliceRadio(); - ServiceCollisions(); + if (!m_bIsPaused) { + m_sPedComments.Process(); + //ServicePoliceRadio(); // LCS: removed + ServiceCollisions(); + } AddReleasingSounds(); - ProcessMissionAudio(); + if (!m_bIsPaused) + ProcessMissionAudio(); #ifdef EXTERNAL_3D_SOUND AdjustSamplesVolume(); #endif @@ -693,7 +688,7 @@ cAudioManager::InterrogateAudioEntities() } void -cAudioManager::AddSampleToRequestedQueue() +cAudioManager::AddSampleToRequestedQueue(uint8 unk_lcs) { uint32 finalPriority; uint8 sampleIndex; @@ -732,6 +727,7 @@ cAudioManager::AddSampleToRequestedQueue() m_sQueueSample.m_bReverb = FALSE; #endif #endif + m_sQueueSample.field_51_lcs = unk_lcs; m_aRequestedQueue[m_nActiveQueue][sampleIndex] = m_sQueueSample; @@ -789,15 +785,15 @@ cAudioManager::AddReflectionsToRequestedQueue() for (uint32 i = 0; i < ARRAY_SIZE(m_afReflectionsDistances); i++) { #ifndef USE_TIME_SCALE_FOR_AUDIO if ( CTimer::GetIsSlowMotionActive() ) - m_afReflectionsDistances[i] = (m_anRandomTable[i % 4] % 3) * 100.0f / 8.0f; + m_afReflectionsDistances[i] = (m_anRandomTable[i % 4] % 3) * 50.0f / 8.0f; #endif reflectionDistance = m_afReflectionsDistances[i]; if (reflectionDistance > 0.0f && reflectionDistance < 100.0f && reflectionDistance < m_sQueueSample.m_MaxDistance) { #ifndef USE_TIME_SCALE_FOR_AUDIO - m_sQueueSample.m_nReflectionDelay = CTimer::GetIsSlowMotionActive() ? (reflectionDistance * 800.0f / 1029.0f) : (reflectionDistance * 500.0f / 1029.0f); + m_sQueueSample.m_nReflectionDelay = CTimer::GetIsSlowMotionActive() ? (reflectionDistance * 600.0f / 1029.0f) : (reflectionDistance * 300.0f / 1029.0f); #else - m_sQueueSample.m_nReflectionDelay = reflectionDistance * 500.0f / 1029.0f; + m_sQueueSample.m_nReflectionDelay = reflectionDistance * 300.0f / 1029.0f; #endif if (m_sQueueSample.m_nReflectionDelay > 3) { m_sQueueSample.m_fDistance = m_afReflectionsDistances[i]; @@ -1410,6 +1406,45 @@ cAudioManager::LoadBankIfNecessary(uint8 bank) } #endif +void +cAudioManager::DirectlyEnqueueSample(uint32 sample, uint8 bank, uint32 counter, uint32 priority, uint32 freq, uint8 volume, uint8 framesToPlay, uint32 notStereo) +{ +#ifdef FIX_BUGS + if (!m_bIsInitialised || m_nExtraSoundsEntity < 0) return; + m_sQueueSample.m_nEntityIndex = m_nExtraSoundsEntity; // not setting entity ID could cause bugs, let's use extra sounds one +#endif + m_sQueueSample.m_nSampleIndex = sample; + m_sQueueSample.m_nBankIndex = bank; + m_sQueueSample.m_nCounter = counter; + m_sQueueSample.m_nFrequency = freq; + m_sQueueSample.m_nVolume = volume; + SET_EMITTING_VOLUME(volume); + m_sQueueSample.m_nPriority = priority; + m_sQueueSample.m_nFramesToPlay = framesToPlay; + SET_SOUND_REFLECTION(FALSE); + m_sQueueSample.m_nLoopCount = 0; + SET_LOOP_OFFSETS(sample) +#ifdef FIX_BUGS + m_sQueueSample.m_bIs2D = TRUE; +#else + m_sQueueSample.m_bIs2D = FALSE; +#endif + m_sQueueSample.m_bStatic = FALSE; + SET_SOUND_REVERB(FALSE); +#ifdef FIX_BUGS + m_sQueueSample.m_nPan = 63; + AddSampleToRequestedQueue(); +#else + // this is dumb and wrong, what were they thinking? + m_sQueueSample.m_nPan = 0; + AudioManager.AddSampleToRequestedQueue(); + if (!notStereo) { + m_sQueueSample.m_nPan = 127; + AudioManager.AddSampleToRequestedQueue(); + } +#endif +} + #ifdef EXTERNAL_3D_SOUND void cAudioManager::AdjustSamplesVolume() |