Fix cAudioManager::ProcessVehicleEngine return type, rename Sound Intensity

This commit is contained in:
Sergeanur 2021-08-16 10:00:10 +03:00
parent 9ed94f310a
commit c7e05c74b9
4 changed files with 380 additions and 379 deletions

View File

@ -268,7 +268,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;
@ -297,7 +297,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

@ -687,7 +687,6 @@ cAudioManager::AddDetailsToRequestedOrderList(uint8 sample)
m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample; m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample;
} }
#ifdef GTA_PC
void void
cAudioManager::AddReflectionsToRequestedQueue() cAudioManager::AddReflectionsToRequestedQueue()
{ {
@ -709,7 +708,7 @@ cAudioManager::AddReflectionsToRequestedQueue()
} else { } else {
emittingVolume = (9 * m_sQueueSample.m_nVolume) / 16; emittingVolume = (9 * m_sQueueSample.m_nVolume) / 16;
} }
m_sQueueSample.m_fSoundIntensity /= 2.f; m_sQueueSample.m_SoundIntensity /= 2.f;
int halfOldFreq = oldFreq >> 1; int halfOldFreq = oldFreq >> 1;
@ -718,12 +717,12 @@ cAudioManager::AddReflectionsToRequestedQueue()
m_afReflectionsDistances[i] = (m_anRandomTable[i % 4] % 3) * 100.f / 8.f; m_afReflectionsDistances[i] = (m_anRandomTable[i % 4] % 3) * 100.f / 8.f;
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 = CTimer::GetIsSlowMotionActive() ? (reflectionDistance * 800.f / 1029.f) : (reflectionDistance * 500.f / 1029.f); m_sQueueSample.m_nLoopsRemaining = CTimer::GetIsSlowMotionActive() ? (reflectionDistance * 800.f / 1029.f) : (reflectionDistance * 500.f / 1029.f);
if (m_sQueueSample.m_nLoopsRemaining > 3) { if (m_sQueueSample.m_nLoopsRemaining > 3) {
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 = oldCounter + (i + 1) * 256; m_sQueueSample.m_nCounter = oldCounter + (i + 1) * 256;
@ -752,43 +751,44 @@ cAudioManager::AddReflectionsToRequestedQueue()
void void
cAudioManager::UpdateReflections() cAudioManager::UpdateReflections()
{ {
CVector camPos = TheCamera.GetPosition(); CVector camPos;
CColPoint colpoint; CColPoint colpoint;
CEntity *ent; CEntity *ent;
if (m_FrameCounter % 8 == 0) { if (m_FrameCounter % 8 == 0) {
camPos = TheCamera.GetPosition();
m_avecReflectionsPos[0] = camPos; m_avecReflectionsPos[0] = camPos;
m_avecReflectionsPos[0].y += 100.f; m_avecReflectionsPos[0].y += 100.f;
if (CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[0], colpoint, ent, true, false, false, true, false, true, true)) if (CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[0], colpoint, ent, true, false, false, true, false, true, true))
m_afReflectionsDistances[0] = Distance(camPos, colpoint.point); m_afReflectionsDistances[0] = Distance(camPos, colpoint.point);
else else
m_afReflectionsDistances[0] = 100.0f; m_afReflectionsDistances[0] = 100.0f;
} else if ((m_FrameCounter + 1) % 8 == 0) { } else if ((m_FrameCounter + 1) % 8 == 0) {
camPos = TheCamera.GetPosition();
m_avecReflectionsPos[1] = camPos; m_avecReflectionsPos[1] = camPos;
m_avecReflectionsPos[1].y -= 100.0f; m_avecReflectionsPos[1].y -= 100.0f;
if (CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[1], colpoint, ent, true, false, false, true, false, true, true)) if (CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[1], colpoint, ent, true, false, false, true, false, true, true))
m_afReflectionsDistances[1] = Distance(camPos, colpoint.point); m_afReflectionsDistances[1] = Distance(camPos, colpoint.point);
else else
m_afReflectionsDistances[1] = 100.0f; m_afReflectionsDistances[1] = 100.0f;
} else if ((m_FrameCounter + 2) % 8 == 0) { } else if ((m_FrameCounter + 2) % 8 == 0) {
camPos = TheCamera.GetPosition();
m_avecReflectionsPos[2] = camPos; m_avecReflectionsPos[2] = camPos;
m_avecReflectionsPos[2].x -= 100.0f; m_avecReflectionsPos[2].x -= 100.0f;
if (CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[2], colpoint, ent, true, false, false, true, false, true, true)) if (CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[2], colpoint, ent, true, false, false, true, false, true, true))
m_afReflectionsDistances[2] = Distance(camPos, colpoint.point); m_afReflectionsDistances[2] = Distance(camPos, colpoint.point);
else else
m_afReflectionsDistances[2] = 100.0f; m_afReflectionsDistances[2] = 100.0f;
} else if ((m_FrameCounter + 3) % 8 == 0) { } else if ((m_FrameCounter + 3) % 8 == 0) {
camPos = TheCamera.GetPosition();
m_avecReflectionsPos[3] = camPos; m_avecReflectionsPos[3] = camPos;
m_avecReflectionsPos[3].x += 100.0f; m_avecReflectionsPos[3].x += 100.0f;
if (CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[3], colpoint, ent, true, false, false, true, false, true, true)) if (CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[3], colpoint, ent, true, false, false, true, false, true, true))
m_afReflectionsDistances[3] = Distance(camPos, colpoint.point); m_afReflectionsDistances[3] = Distance(camPos, colpoint.point);
else else
m_afReflectionsDistances[3] = 100.0f; m_afReflectionsDistances[3] = 100.0f;
} else if ((m_FrameCounter + 4) % 8 == 0) { } else if ((m_FrameCounter + 4) % 8 == 0) {
camPos = TheCamera.GetPosition();
camPos.y += 1.0f; camPos.y += 1.0f;
m_avecReflectionsPos[4] = camPos; m_avecReflectionsPos[4] = camPos;
m_avecReflectionsPos[4].z += 100.0f; m_avecReflectionsPos[4].z += 100.0f;
@ -796,8 +796,8 @@ cAudioManager::UpdateReflections()
m_afReflectionsDistances[4] = colpoint.point.z - camPos.z; m_afReflectionsDistances[4] = colpoint.point.z - camPos.z;
else else
m_afReflectionsDistances[4] = 100.0f; m_afReflectionsDistances[4] = 100.0f;
} else if ((m_FrameCounter + 5) % 8 == 0) { } else if ((m_FrameCounter + 5) % 8 == 0) {
camPos = TheCamera.GetPosition();
camPos.y -= 1.0f; camPos.y -= 1.0f;
m_avecReflectionsPos[5] = camPos; m_avecReflectionsPos[5] = camPos;
m_avecReflectionsPos[5].z += 100.0f; m_avecReflectionsPos[5].z += 100.0f;
@ -805,8 +805,8 @@ cAudioManager::UpdateReflections()
m_afReflectionsDistances[5] = colpoint.point.z - camPos.z; m_afReflectionsDistances[5] = colpoint.point.z - camPos.z;
else else
m_afReflectionsDistances[5] = 100.0f; m_afReflectionsDistances[5] = 100.0f;
} else if ((m_FrameCounter + 6) % 8 == 0) { } else if ((m_FrameCounter + 6) % 8 == 0) {
camPos = TheCamera.GetPosition();
camPos.x -= 1.0f; camPos.x -= 1.0f;
m_avecReflectionsPos[6] = camPos; m_avecReflectionsPos[6] = camPos;
m_avecReflectionsPos[6].z += 100.0f; m_avecReflectionsPos[6].z += 100.0f;
@ -814,8 +814,8 @@ cAudioManager::UpdateReflections()
m_afReflectionsDistances[6] = colpoint.point.z - camPos.z; m_afReflectionsDistances[6] = colpoint.point.z - camPos.z;
else else
m_afReflectionsDistances[6] = 100.0f; m_afReflectionsDistances[6] = 100.0f;
} else if ((m_FrameCounter + 7) % 8 == 0) { } else if ((m_FrameCounter + 7) % 8 == 0) {
camPos = TheCamera.GetPosition();
camPos.x += 1.0f; camPos.x += 1.0f;
m_avecReflectionsPos[7] = camPos; m_avecReflectionsPos[7] = camPos;
m_avecReflectionsPos[7].z += 100.0f; m_avecReflectionsPos[7].z += 100.0f;
@ -825,7 +825,6 @@ cAudioManager::UpdateReflections()
m_afReflectionsDistances[7] = 100.0f; m_afReflectionsDistances[7] = 100.0f;
} }
} }
#endif // GTA_PC
void void
cAudioManager::AddReleasingSounds() cAudioManager::AddReleasingSounds()
@ -853,7 +852,7 @@ cAudioManager::AddReleasingSounds()
} }
} }
if (!toProcess[i]) { if (!toProcess[i]) {
if (sample.m_nCounter <= 255 || !sample.m_nLoopsRemaining) { if (sample.m_nCounter <= 255 || sample.m_nLoopsRemaining == 0) {
if (sample.m_nReleasingVolumeDivider == 0) if (sample.m_nReleasingVolumeDivider == 0)
continue; continue;
if (sample.m_nLoopCount == 0) { if (sample.m_nLoopCount == 0) {
@ -995,7 +994,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);
@ -1084,14 +1083,14 @@ cAudioManager::ProcessActiveQueues()
usedX = x; usedX = x;
usedY = 0.0f; usedY = 0.0f;
usedZ = 0.0f; usedZ = 0.0f;
m_asActiveSamples[k].m_fSoundIntensity = 100000.0f; m_asActiveSamples[k].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(k, usedX, usedY, usedZ); SampleManager.SetChannel3DPosition(k, usedX, usedY, usedZ);
SampleManager.SetChannel3DDistances(k, m_asActiveSamples[k].m_fSoundIntensity, 0.25f * m_asActiveSamples[k].m_fSoundIntensity); SampleManager.SetChannel3DDistances(k, m_asActiveSamples[k].m_SoundIntensity, 0.25f * m_asActiveSamples[k].m_SoundIntensity);
#endif #endif
SampleManager.StartChannel(k); SampleManager.StartChannel(k);
} }
@ -1140,7 +1139,7 @@ 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;
m_asActiveSamples[i].m_nCalculatedVolume = 0; m_asActiveSamples[i].m_nCalculatedVolume = 0;
@ -1176,7 +1175,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

@ -27,10 +27,12 @@ public:
uint8 m_nEmittingVolume; uint8 m_nEmittingVolume;
#endif #endif
float m_fSpeedMultiplier; float m_fSpeedMultiplier;
float m_fSoundIntensity; float m_SoundIntensity;
bool8 m_bReleasingSoundFlag; bool8 m_bReleasingSoundFlag;
CVector m_vecPos; CVector m_vecPos;
bool8 m_bReverbFlag; #ifndef GTA_PS2
bool8 m_bReverbFlag; // TODO: ifdef all the occurrences
#endif
uint8 m_nLoopsRemaining; uint8 m_nLoopsRemaining;
bool8 m_bRequireReflection; // Used for oneshots bool8 m_bRequireReflection; // Used for oneshots
uint8 m_nOffset; uint8 m_nOffset;
@ -219,10 +221,8 @@ public:
tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES]; tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES];
int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES]; int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES];
int32 m_nAudioEntitiesTotal; int32 m_nAudioEntitiesTotal;
#ifdef GTA_PC
CVector m_avecReflectionsPos[NUM_AUDIO_REFLECTIONS]; CVector m_avecReflectionsPos[NUM_AUDIO_REFLECTIONS];
float m_afReflectionsDistances[NUM_AUDIO_REFLECTIONS]; float m_afReflectionsDistances[NUM_AUDIO_REFLECTIONS];
#endif
cAudioScriptObjectManager m_sAudioScriptObjectManager; cAudioScriptObjectManager m_sAudioScriptObjectManager;
// miami // miami
@ -301,10 +301,8 @@ public:
void InterrogateAudioEntities(); // inlined void InterrogateAudioEntities(); // inlined
void AddSampleToRequestedQueue(); void AddSampleToRequestedQueue();
void AddDetailsToRequestedOrderList(uint8 sample); // inlined in vc void AddDetailsToRequestedOrderList(uint8 sample); // inlined in vc
#ifdef GTA_PC
void AddReflectionsToRequestedQueue(); void AddReflectionsToRequestedQueue();
void UpdateReflections(); void UpdateReflections();
#endif
void AddReleasingSounds(); void AddReleasingSounds();
void ProcessActiveQueues(); void ProcessActiveQueues();
void ClearRequestedQueue(); // inlined in vc void ClearRequestedQueue(); // inlined in vc
@ -341,7 +339,7 @@ public:
void ProcessVehicleFlatTyre(cVehicleParams &params); void ProcessVehicleFlatTyre(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(CVehicle *veh, int vehType); void UpdateGasPedalAudio(CVehicle *veh, int vehType);
void PlayerJustGotInCar(); void PlayerJustGotInCar();
void PlayerJustLeftCar(); void PlayerJustLeftCar();