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

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

View file

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