Fix cAudioManager::ProcessVehicleEngine return type, document PS2 changes, rename Sound Intensity

This commit is contained in:
Sergeanur 2021-08-15 13:14:16 +03:00
parent 886650a887
commit 5ddd0649e3
4 changed files with 266 additions and 244 deletions

View File

@ -266,7 +266,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col)
SET_EMITTING_VOLUME(emittingVol); SET_EMITTING_VOLUME(emittingVol);
RESET_LOOP_OFFSETS RESET_LOOP_OFFSETS
m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSpeedMultiplier = 4.0f;
m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; m_sQueueSample.m_SoundIntensity = CollisionSoundIntensity;
m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_bReleasingSoundFlag = TRUE;
m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bReverbFlag = TRUE;
m_sQueueSample.m_bRequireReflection = FALSE; m_sQueueSample.m_bRequireReflection = FALSE;
@ -295,7 +295,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun
SET_EMITTING_VOLUME(emittingVol); SET_EMITTING_VOLUME(emittingVol);
SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSpeedMultiplier = 4.0f;
m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; m_sQueueSample.m_SoundIntensity = CollisionSoundIntensity;
m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_bReleasingSoundFlag = FALSE;
m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_nReleasingVolumeDivider = 5;
m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bReverbFlag = TRUE;

File diff suppressed because it is too large Load Diff

View File

@ -114,7 +114,7 @@ cAudioManager::Service()
if (m_bIsInitialised) { if (m_bIsInitialised) {
m_nPreviousUserPause = m_nUserPause; m_nPreviousUserPause = m_nUserPause;
m_nUserPause = CTimer::GetIsUserPaused(); m_nUserPause = CTimer::GetIsUserPaused();
#ifdef GTA_PC #if GTA_VERSION >= GTA3_PC_10
UpdateReflections(); UpdateReflections();
#endif #endif
ServiceSoundEffects(); ServiceSoundEffects();
@ -657,7 +657,7 @@ cAudioManager::AddDetailsToRequestedOrderList(uint8 sample)
m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample; m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample;
} }
#ifdef GTA_PC #if GTA_VERSION >= GTA3_PC_10
void void
cAudioManager::AddReflectionsToRequestedQueue() cAudioManager::AddReflectionsToRequestedQueue()
{ {
@ -667,12 +667,12 @@ cAudioManager::AddReflectionsToRequestedQueue()
for (uint32 i = 0; i < ARRAY_SIZE(m_afReflectionsDistances); i++) { for (uint32 i = 0; i < ARRAY_SIZE(m_afReflectionsDistances); i++) {
reflectionDistance = m_afReflectionsDistances[i]; reflectionDistance = m_afReflectionsDistances[i];
if (reflectionDistance > 0.0f && reflectionDistance < 100.f && reflectionDistance < m_sQueueSample.m_fSoundIntensity) { if (reflectionDistance > 0.0f && reflectionDistance < 100.f && reflectionDistance < m_sQueueSample.m_SoundIntensity) {
m_sQueueSample.m_nLoopsRemaining = (reflectionDistance * 500.f / 1029.f); m_sQueueSample.m_nLoopsRemaining = (reflectionDistance * 500.f / 1029.f);
if (m_sQueueSample.m_nLoopsRemaining > 5) { if (m_sQueueSample.m_nLoopsRemaining > 5) {
m_sQueueSample.m_fDistance = m_afReflectionsDistances[i]; m_sQueueSample.m_fDistance = m_afReflectionsDistances[i];
SET_EMITTING_VOLUME(emittingVolume); SET_EMITTING_VOLUME(emittingVolume);
m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance);
if (m_sQueueSample.m_nVolume > emittingVolume / 16) { if (m_sQueueSample.m_nVolume > emittingVolume / 16) {
m_sQueueSample.m_nCounter += (i + 1) * 256; m_sQueueSample.m_nCounter += (i + 1) * 256;
if (m_sQueueSample.m_nLoopCount) { if (m_sQueueSample.m_nLoopCount) {
@ -884,7 +884,7 @@ cAudioManager::ProcessActiveQueues()
TranslateEntity(&sample.m_vecPos, &position); TranslateEntity(&sample.m_vecPos, &position);
#ifdef EXTERNAL_3D_SOUND #ifdef EXTERNAL_3D_SOUND
SampleManager.SetChannel3DPosition(j, position.x, position.y, position.z); SampleManager.SetChannel3DPosition(j, position.x, position.y, position.z);
SampleManager.SetChannel3DDistances(j, sample.m_fSoundIntensity, 0.25f * sample.m_fSoundIntensity); SampleManager.SetChannel3DDistances(j, sample.m_SoundIntensity, 0.25f * sample.m_SoundIntensity);
#else #else
sample.m_nOffset = ComputePan(sample.m_fDistance, &position); sample.m_nOffset = ComputePan(sample.m_fDistance, &position);
SampleManager.SetChannelPan(j, sample.m_nOffset); SampleManager.SetChannelPan(j, sample.m_nOffset);
@ -957,14 +957,14 @@ cAudioManager::ProcessActiveQueues()
usedX = x; usedX = x;
usedY = 0.0f; usedY = 0.0f;
usedZ = 0.0f; usedZ = 0.0f;
m_asActiveSamples[j].m_fSoundIntensity = 100000.0f; m_asActiveSamples[j].m_SoundIntensity = 100000.0f;
} else { } else {
usedX = position.x; usedX = position.x;
usedY = position.y; usedY = position.y;
usedZ = position.z; usedZ = position.z;
} }
SampleManager.SetChannel3DPosition(j, usedX, usedY, usedZ); SampleManager.SetChannel3DPosition(j, usedX, usedY, usedZ);
SampleManager.SetChannel3DDistances(j, m_asActiveSamples[j].m_fSoundIntensity, 0.25f * m_asActiveSamples[j].m_fSoundIntensity); SampleManager.SetChannel3DDistances(j, m_asActiveSamples[j].m_SoundIntensity, 0.25f * m_asActiveSamples[j].m_SoundIntensity);
#endif #endif
SampleManager.StartChannel(j); SampleManager.StartChannel(j);
} }
@ -1012,16 +1012,21 @@ cAudioManager::ClearActiveSamples()
m_asActiveSamples[i].m_nLoopEnd = -1; m_asActiveSamples[i].m_nLoopEnd = -1;
#endif #endif
m_asActiveSamples[i].m_fSpeedMultiplier = 0.0f; m_asActiveSamples[i].m_fSpeedMultiplier = 0.0f;
m_asActiveSamples[i].m_fSoundIntensity = 200.0f; m_asActiveSamples[i].m_SoundIntensity = 200.0f;
m_asActiveSamples[i].m_nOffset = 63; m_asActiveSamples[i].m_nOffset = 63;
m_asActiveSamples[i].m_bReleasingSoundFlag = FALSE; m_asActiveSamples[i].m_bReleasingSoundFlag = FALSE;
#if GTA_VERSION < GTA3_PC_10
m_asActiveSamples[i].unk = -3;
#endif
m_asActiveSamples[i].m_nCalculatedVolume = 0; m_asActiveSamples[i].m_nCalculatedVolume = 0;
m_asActiveSamples[i].m_nReleasingVolumeDivider = 0; m_asActiveSamples[i].m_nReleasingVolumeDivider = 0;
m_asActiveSamples[i].m_nVolumeChange = -1; m_asActiveSamples[i].m_nVolumeChange = -1;
m_asActiveSamples[i].m_vecPos = CVector(0.0f, 0.0f, 0.0f); m_asActiveSamples[i].m_vecPos = CVector(0.0f, 0.0f, 0.0f);
m_asActiveSamples[i].m_bReverbFlag = FALSE; m_asActiveSamples[i].m_bReverbFlag = FALSE;
#if GTA_VERSION >= GTA3_PC_10
m_asActiveSamples[i].m_nLoopsRemaining = 0; m_asActiveSamples[i].m_nLoopsRemaining = 0;
m_asActiveSamples[i].m_bRequireReflection = FALSE; m_asActiveSamples[i].m_bRequireReflection = FALSE;
#endif
} }
} }
@ -1048,7 +1053,7 @@ cAudioManager::AdjustSamplesVolume()
tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]];
if (!pSample->m_bIs2D) if (!pSample->m_bIs2D)
pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_fSoundIntensity, pSample->m_fDistance); pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_SoundIntensity, pSample->m_fDistance);
} }
} }

View File

@ -8,7 +8,11 @@ class tSound
{ {
public: public:
int32 m_nEntityIndex; int32 m_nEntityIndex;
#if GTA_VERSION >= GTA3_PC_10
int32 m_nCounter; int32 m_nCounter;
#else
uint8 m_nCounter;
#endif
int32 m_nSampleIndex; int32 m_nSampleIndex;
uint8 m_nBankIndex; uint8 m_nBankIndex;
bool8 m_bIs2D; bool8 m_bIs2D;
@ -25,16 +29,25 @@ public:
uint8 m_nEmittingVolume; uint8 m_nEmittingVolume;
#endif #endif
float m_fSpeedMultiplier; float m_fSpeedMultiplier;
float m_fSoundIntensity; #if GTA_VERSION >= GTA3_PC_10
float m_SoundIntensity;
#else
uint32 m_SoundIntensity;
#endif
bool8 m_bReleasingSoundFlag; bool8 m_bReleasingSoundFlag;
CVector m_vecPos; CVector m_vecPos;
bool8 m_bReverbFlag; bool8 m_bReverbFlag;
#if GTA_VERSION >= GTA3_PC_10
uint8 m_nLoopsRemaining; uint8 m_nLoopsRemaining;
bool8 m_bRequireReflection; // Used for oneshots bool8 m_bRequireReflection; // Used for oneshots
#endif
uint8 m_nOffset; uint8 m_nOffset;
int32 m_nReleasingVolumeDivider; int32 m_nReleasingVolumeDivider;
bool8 m_bIsProcessed; bool8 m_bIsProcessed;
bool8 m_bLoopEnded; bool8 m_bLoopEnded;
#if GTA_VERSION < GTA3_PC_10
int32 unk; // only on PS2, seems unused
#endif
int32 m_nCalculatedVolume; int32 m_nCalculatedVolume;
int8 m_nVolumeChange; int8 m_nVolumeChange;
}; };
@ -276,7 +289,7 @@ public:
void InterrogateAudioEntities(); // inlined on PS2 void InterrogateAudioEntities(); // inlined on PS2
void AddSampleToRequestedQueue(); void AddSampleToRequestedQueue();
void AddDetailsToRequestedOrderList(uint8 sample); // inlined on PS2 void AddDetailsToRequestedOrderList(uint8 sample); // inlined on PS2
#ifdef GTA_PC #if GTA_VERSION >= GTA3_PC_10
void AddReflectionsToRequestedQueue(); void AddReflectionsToRequestedQueue();
void UpdateReflections(); void UpdateReflections();
#endif #endif
@ -312,7 +325,7 @@ public:
void ProcessModelCarEngine(cVehicleParams &params); void ProcessModelCarEngine(cVehicleParams &params);
bool8 ProcessVehicleRoadNoise(cVehicleParams &params); bool8 ProcessVehicleRoadNoise(cVehicleParams &params);
bool8 ProcessWetRoadNoise(cVehicleParams &params); bool8 ProcessWetRoadNoise(cVehicleParams &params);
void ProcessVehicleEngine(cVehicleParams &params); bool8 ProcessVehicleEngine(cVehicleParams &params);
void UpdateGasPedalAudio(CAutomobile *automobile); // inlined on PS2 void UpdateGasPedalAudio(CAutomobile *automobile); // inlined on PS2
void PlayerJustGotInCar(); void PlayerJustGotInCar();
void PlayerJustLeftCar(); void PlayerJustLeftCar();