road noise

This commit is contained in:
Roman Masanin 2020-10-17 02:22:02 +03:00
parent 894a1ae93a
commit 97fc5224e7
2 changed files with 102 additions and 72 deletions

View File

@ -972,7 +972,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams *params)
bool
cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params)
cAudioManager::ProcessVehicleRoadNoise(cVehicleParams* params)
{
const float SOUND_INTENSITY = 95.0f;
@ -981,11 +981,27 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params)
float modificator;
int sampleFreq;
float velocity;
uint8 wheelsOnGround;
if (params->m_fDistance >= SQR(SOUND_INTENSITY))
return false;
if (params->m_pTransmission != nil) {
if (((CAutomobile*)params->m_pVehicle)->m_nDriveWheelsOnGround != 0) {
if (params->m_fDistance >= SQR(SOUND_INTENSITY))
return false;
switch (params->m_VehicleType) {
case VEHICLE_TYPE_CAR:
wheelsOnGround = ((CAutomobile*)params->m_pVehicle)->m_nWheelsOnGround;
break;
case VEHICLE_TYPE_BIKE:
wheelsOnGround = ((CBike*)params->m_pVehicle)->m_nWheelsOnGround;
break;
default:
wheelsOnGround = 4;
break;
}
if (params->m_pTransmission == nil || wheelsOnGround == 0)
return true;
velocity = Abs(params->m_fVelocityChange);
if (velocity > 0.0f) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
@ -1001,7 +1017,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params)
freq = 6050 * emittingVol / 30 + 16000;
} else {
m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE;
modificator = m_sQueueSample.m_fDistance / 190.f;
modificator = (m_sQueueSample.m_fDistance / 95.0f) * 0.5f; //mb SOUND_INTENSITY?
sampleFreq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE);
freq = (sampleFreq * modificator) + ((3 * sampleFreq) / 4);
}
@ -1019,13 +1035,12 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params)
AddSampleToRequestedQueue();
}
}
}
}
return true;
}
bool
cAudioManager::ProcessWetRoadNoise(cVehicleParams *params)
cAudioManager::ProcessWetRoadNoise(cVehicleParams* params)
{
const float SOUND_INTENSITY = 30.0f;
@ -1033,16 +1048,29 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params)
int32 emittingVol;
float modificator;
int freq;
float velChange;
float velocity;
uint8 wheelsOnGround;
if (params->m_fDistance >= SQR(SOUND_INTENSITY))
return false;
if (params->m_pTransmission != nil) {
if (((CAutomobile *)params->m_pVehicle)->m_nDriveWheelsOnGround != 0) {
velChange = Abs(params->m_fVelocityChange);
if (velChange > 0.f) {
switch (params->m_VehicleType) {
case VEHICLE_TYPE_CAR:
wheelsOnGround = ((CAutomobile*)params->m_pVehicle)->m_nWheelsOnGround;
break;
case VEHICLE_TYPE_BIKE:
wheelsOnGround = ((CBike*)params->m_pVehicle)->m_nWheelsOnGround;
break;
default:
wheelsOnGround = 4;
break;
}
if (params->m_pTransmission == nil || wheelsOnGround == 0)
return true;
velocity = Abs(params->m_fVelocityChange);
if (velocity > 0.0f) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
relativeVelocity = Min(1.0f, velChange / (0.5f * params->m_pTransmission->fMaxVelocity));
relativeVelocity = Min(1.0f, velocity / (0.5f * params->m_pTransmission->fMaxVelocity));
emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads;
m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
if (m_sQueueSample.m_nVolume != 0) {
@ -1051,7 +1079,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params)
m_sQueueSample.m_nBankIndex = SFX_BANK_0;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
modificator = m_sQueueSample.m_fDistance / 6.f;
modificator = (m_sQueueSample.m_fDistance / 30.0f) * 0.5f; //need recheck in III, mb sount_intensity?
freq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE);
m_sQueueSample.m_nFrequency = freq + freq * modificator;
m_sQueueSample.m_nLoopCount = 0;
@ -1067,8 +1095,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params)
AddSampleToRequestedQueue();
}
}
}
}
return true;
}
@ -2132,13 +2159,15 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params)
const float SOUND_INTENSITY = 50.0f;
CVehicle *veh = params->m_pVehicle;
uint8 volume;
if (params->m_fDistance >= SQR(SOUND_INTENSITY))
return false;
if (veh->bEngineOn && veh->m_fGasPedal < 0.0f) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
m_sQueueSample.m_nVolume = ComputeVolume(60, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
volume = veh->bIsDrowning ? 15 : 60;
m_sQueueSample.m_nVolume = ComputeVolume(volume, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nCounter = 12;
m_sQueueSample.m_nSampleIndex = SFX_REVERSE_WARNING;
@ -2147,7 +2176,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params)
m_sQueueSample.m_nReleasingVolumeModificator = 2;
m_sQueueSample.m_nFrequency = (100 * m_sQueueSample.m_nEntityIndex & 1023) + SampleManager.GetSampleBaseFrequency(SFX_REVERSE_WARNING);
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_nEmittingVolume = 60;
m_sQueueSample.m_nEmittingVolume = 60; //mb bug?
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 3.0f;
@ -2803,6 +2832,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params)
}
}
}
#ifdef GTA_TRAIN
bool
cAudioManager::ProcessTrainNoise(cVehicleParams *params)

View File

@ -361,13 +361,13 @@ public:
void UpdateGasPedalAudio(CVehicle* veh, int vehType); // done
bool ProcessVehicleHorn(cVehicleParams *params); // done
void ProcessVehicleOneShots(cVehicleParams *params); //
bool ProcessVehicleReverseWarning(cVehicleParams *params); //
bool ProcessVehicleRoadNoise(cVehicleParams *params); //
bool ProcessVehicleReverseWarning(cVehicleParams *params); // done
bool ProcessVehicleRoadNoise(cVehicleParams *params); // done
bool ProcessVehicleSirenOrAlarm(cVehicleParams *params); // done
bool ProcessVehicleSkidding(cVehicleParams *params); //
void ProcessWaterCannon(int32); //
void ProcessWeather(int32 id); // done
bool ProcessWetRoadNoise(cVehicleParams *params); //
bool ProcessWetRoadNoise(cVehicleParams *params); // done
void ProcessEscalators(); // done
void ProcessExtraSounds(); // done