1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 09:30:00 +00:00

Audio fixes

This commit is contained in:
Sergeanur 2020-07-16 22:30:55 +03:00
parent ec09055599
commit 81c03f8e6d
2 changed files with 41 additions and 44 deletions

View file

@ -980,7 +980,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params)
relativeGearChange = relativeGearChange =
Min(1.0f, (params->m_fVelocityChange - transmission->Gears[currentGear].fShiftDownVelocity) / transmission->fMaxVelocity * 2.5f); Min(1.0f, (params->m_fVelocityChange - transmission->Gears[currentGear].fShiftDownVelocity) / transmission->fMaxVelocity * 2.5f);
if (traction == 0.0f && automobile->GetStatus() != STATUS_SIMPLE && if (traction == 0.0f && automobile->GetStatus() != STATUS_SIMPLE &&
params->m_fVelocityChange >= transmission->Gears[1].fShiftUpVelocity) { params->m_fVelocityChange < transmission->Gears[1].fShiftUpVelocity) {
traction = 0.7f; traction = 0.7f;
} }
relativeChange = traction * automobile->m_fGasPedalAudio * 0.95f + (1.0f - traction) * relativeGearChange; relativeChange = traction * automobile->m_fGasPedalAudio * 0.95f + (1.0f - traction) * relativeGearChange;
@ -993,7 +993,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params)
relativeChange = automobile->m_fGasPedalAudio; relativeChange = automobile->m_fGasPedalAudio;
} }
modificator = relativeChange; modificator = relativeChange;
if (currentGear || !automobile->m_nWheelsOnGround) if (currentGear != 0 || automobile->m_nWheelsOnGround == 0)
freq = 1200 * currentGear + 18000.f * modificator + 14000; freq = 1200 * currentGear + 18000.f * modificator + 14000;
else else
freq = 13000.f * modificator + 14000; freq = 13000.f * modificator + 14000;
@ -1279,7 +1279,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
SampleManager.StopChannel(m_nActiveSamples); SampleManager.StopChannel(m_nActiveSamples);
bAccelSampleStopped = true; bAccelSampleStopped = true;
} }
if (!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction) if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction)
gasPedalAudio = automobile->m_fGasPedalAudio; gasPedalAudio = automobile->m_fGasPedalAudio;
else else
gasPedalAudio = Min(1.0f, params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity); gasPedalAudio = Min(1.0f, params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity);
@ -1292,8 +1292,8 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
bAccelSampleStopped = true; bAccelSampleStopped = true;
} }
nCruising = 0; nCruising = 0;
if (!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction || if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction ||
params->m_fVelocityChange >= 0.01f && automobile->m_fGasPedalAudio > 0.2f) { params->m_fVelocityChange < 0.01f && automobile->m_fGasPedalAudio > 0.2f) {
automobile->m_fGasPedalAudio *= 0.6f; automobile->m_fGasPedalAudio *= 0.6f;
gasPedalAudio = automobile->m_fGasPedalAudio; gasPedalAudio = automobile->m_fGasPedalAudio;
} }
@ -1313,11 +1313,11 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
CurrentPretendGear = Max(1, currentGear); CurrentPretendGear = Max(1, currentGear);
} else { } else {
while (nCruising == 0) { while (nCruising == 0) {
if (accelerateState < 150 || !automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction || if (accelerateState < 150 || automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction ||
currentGear < 2 && velocityChange - automobile->m_fVelocityChangeForAudio < 0.01f) { // here could be used abs currentGear < 2 && velocityChange - automobile->m_fVelocityChangeForAudio < 0.01f) { // here could be used abs
if (!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction) { if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction) {
if (!automobile->m_nWheelsOnGround && automobile->m_nDriveWheelsOnGround || if (automobile->m_nWheelsOnGround == 0 && automobile->m_nDriveWheelsOnGround != 0 ||
(automobile->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame) && automobile->m_nWheelsOnGround) { (automobile->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame) && automobile->m_nWheelsOnGround != 0) {
automobile->m_fGasPedalAudio *= 0.6f; automobile->m_fGasPedalAudio *= 0.6f;
} }
freqModifier = 0; freqModifier = 0;
@ -1381,11 +1381,11 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
} }
if (nCruising != 0) { if (nCruising != 0) {
bAccelSampleStopped = true; bAccelSampleStopped = true;
if (accelerateState < 150 || !automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction || if (accelerateState < 150 || automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction ||
currentGear < params->m_pTransmission->nNumberOfGears - 1) { currentGear < params->m_pTransmission->nNumberOfGears - 1) {
nCruising = 0; nCruising = 0;
} else { } else {
if (accelerateState >= 220 && 0.001f + params->m_fVelocityChange < automobile->m_fVelocityChangeForAudio) { if (accelerateState >= 220 && params->m_fVelocityChange + 0.001f < automobile->m_fVelocityChangeForAudio) {
if (nCruising < 800) if (nCruising < 800)
++nCruising; ++nCruising;
} else if (nCruising > 3) { } else if (nCruising > 3) {
@ -1404,7 +1404,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
bLostTractionLastFrame = lostTraction; bLostTractionLastFrame = lostTraction;
} }
void bool
cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) cAudioManager::ProcessVehicleSkidding(cVehicleParams *params)
{ {
const float SOUND_INTENSITY = 40.0f; const float SOUND_INTENSITY = 40.0f;
@ -1416,10 +1416,10 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params)
float skidVal = 0.0f; float skidVal = 0.0f;
if (params->m_fDistance >= SQR(SOUND_INTENSITY)) if (params->m_fDistance >= SQR(SOUND_INTENSITY))
return; return false;
automobile = (CAutomobile *)params->m_pVehicle; automobile = (CAutomobile *)params->m_pVehicle;
if (!automobile->m_nWheelsOnGround) if (automobile->m_nWheelsOnGround == 0)
return; return true;
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
for (int32 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) { for (int32 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) {
if (automobile->m_aWheelState[i] == WHEEL_STATE_NORMAL || automobile->Damage.GetWheelStatus(i) == WHEEL_STATUS_MISSING) if (automobile->m_aWheelState[i] == WHEEL_STATE_NORMAL || automobile->Damage.GetWheelStatus(i) == WHEEL_STATUS_MISSING)
@ -1459,6 +1459,8 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params)
emittingVol /= 4; emittingVol /= 4;
m_sQueueSample.m_nFrequency = 13000.f * skidVal + 35000.f; m_sQueueSample.m_nFrequency = 13000.f * skidVal + 35000.f;
m_sQueueSample.m_nVolume /= 4; m_sQueueSample.m_nVolume /= 4;
if (m_sQueueSample.m_nVolume == 0)
return true;
break; break;
case SURFACE_GRAVEL: case SURFACE_GRAVEL:
case SURFACE_MUD_DRY: case SURFACE_MUD_DRY:
@ -1490,43 +1492,40 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params)
AddSampleToRequestedQueue(); AddSampleToRequestedQueue();
} }
} }
return true;
} }
float float
cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange) cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange)
{ {
tWheelState wheelState; float relativeVelChange = 0.0f;
float relativeVelChange;
float gasPedalAudio = automobile->m_fGasPedalAudio; float gasPedalAudio = automobile->m_fGasPedalAudio;
float modificator;
float velChange; float velChange;
float relativeVel; float relativeVel;
wheelState = automobile->m_aWheelState[wheel]; switch (automobile->m_aWheelState[wheel])
if (wheelState == WHEEL_STATE_SPINNING && gasPedalAudio > 0.4f) { {
relativeVelChange = (gasPedalAudio - 0.4f) * 1.25f; case WHEEL_STATE_SPINNING:
if (gasPedalAudio > 0.4f)
} else if (wheelState == WHEEL_STATE_SKIDDING) { relativeVelChange = (gasPedalAudio - 0.4f) * 1.6666666f * 0.75f;
break;
case WHEEL_STATE_SKIDDING:
relativeVelChange = Min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity); relativeVelChange = Min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity);
} else if (wheelState == WHEEL_STATE_FIXED) { break;
modificator = 0.4f; case WHEEL_STATE_FIXED:
relativeVelChange = gasPedalAudio; relativeVel = gasPedalAudio;
if (relativeVelChange > 0.4f) { if (relativeVel > 0.4f)
relativeVelChange = relativeVelChange - 0.4f; relativeVel = (gasPedalAudio - 0.4f) * 1.6666666f;
modificator = 5.f / 3.f;
}
velChange = Abs(velocityChange); velChange = Abs(velocityChange);
if (relativeVelChange > 0.4f) if (velChange > 0.04f)
relativeVelChange = relativeVelChange * modificator; relativeVelChange = Min(1.0f, velChange / transmission->fMaxVelocity);
if (velChange > 0.04f) { if (relativeVel > relativeVelChange)
relativeVel = Min(1.0f, velChange / transmission->fMaxVelocity);
} else {
relativeVel = 0.0f;
}
if (relativeVel >= relativeVelChange)
relativeVelChange = relativeVel; relativeVelChange = relativeVel;
} else {
relativeVelChange = 0.0f; break;
default:
break;
} }
return Max(relativeVelChange, Min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f)); return Max(relativeVelChange, Min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f));
@ -1535,12 +1534,10 @@ cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobil
float float
cAudioManager::GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange) cAudioManager::GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange)
{ {
float relativeVelChange; float relativeVelChange = 0.0f;
if (automobile->m_aWheelState[wheel] == WHEEL_STATE_SKIDDING) if (automobile->m_aWheelState[wheel] == WHEEL_STATE_SKIDDING)
relativeVelChange = Min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity); relativeVelChange = Min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity);
else
relativeVelChange = 0.0f;
return Max(relativeVelChange, Min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f)); return Max(relativeVelChange, Min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f));
} }

View file

@ -421,7 +421,7 @@ public:
bool ProcessVehicleReverseWarning(cVehicleParams *params); bool ProcessVehicleReverseWarning(cVehicleParams *params);
bool ProcessVehicleRoadNoise(cVehicleParams *params); bool ProcessVehicleRoadNoise(cVehicleParams *params);
bool ProcessVehicleSirenOrAlarm(cVehicleParams *params); bool ProcessVehicleSirenOrAlarm(cVehicleParams *params);
void ProcessVehicleSkidding(cVehicleParams *params); bool ProcessVehicleSkidding(cVehicleParams *params);
void ProcessWaterCannon(int32); void ProcessWaterCannon(int32);
void ProcessWeather(int32 id); void ProcessWeather(int32 id);
bool ProcessWetRoadNoise(cVehicleParams *params); bool ProcessWetRoadNoise(cVehicleParams *params);